完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
如果我有不止一个中断源,我应该选择哪个程序结构?EXP1:如果(TMR1IF=真){T} Esle如果(TMR0IF=真){}} {{} EX2:如果(TMR1IF=真){}(TMR0IF=真){}…
以上来自于百度翻译 以下为原文 If i have more than one interrupt source which program structure should i select? EXP1: If (TMR1IF == TRUE) { } esle if ( TMR0IF == TRUE) { } else { } EXP2: If (TMR1IF == TRUE) { } If (TMR0IF == TRUE) { } . . . |
|
相关推荐
5个回答
|
|
这两种方法都会起作用。这取决于如果两个中断同时被断言,你希望发生什么。我通常会使用第二个表单。
以上来自于百度翻译 以下为原文 Both methods will work. It depends upon what YOU want to happen if two interrupts are asserted at the same time. I'd normally use the second form. |
|
|
|
我的第一个反应是“不”。你需要的是:因为这些设备只有一个或两个中断向量,并且大多数外设将设置它们的IF位,即使设置了相应的IE位,那么这两种方式都会导致Ir代码被IE位CURLE调用。如果第一次在代码中列出错误的ISR代码,而不是实际触发中断的代码,那么第一种方法将执行错误的ISR代码。第二种方法将在每个中断触发器上执行不正确的ISR代码,而不管源代码。现在回答你的问题:假设你使用正确的样式(如上),那么几乎没有什么区别。如果在执行代码时有两个同时中断源激活,那么第一个方法将服务一个,退出,中断再次触发下一个,等等(假设较早的中断没有被再次触发在平均时间)。E是两个同时中断源激活,然后两者将在一个触发器中服务。苏珊
以上来自于百度翻译 以下为原文 My first response would be 'neither'. What you need is something like: if(TMR0IE == 1 && TMR0IF == 1) {...} As these devices have only one or two interrupt vectors, and most peripherals will set their IF bit even if the corresponding IE bit is set, then the both of your ways can result in the ISR code being called with the IE bit cleared. (The first way will execute the incorrect ISR code if it is listed earlier in the code than the one that actually triggered the interrupt. The 2nd way will execute the incorrect ISR code on every interrupt trigger, regardless of the source.) Now to answer your question: assuming that you use the correct style (as above) then there is very little difference. If there are two simultaneous interrupt sources active when the code is executed, then the first way will service one, exit, have the interrupt triggered again for the next one and so on (assuming that the earlier interrupt has not been triggered again in the mean time). With the 2nd style when there are two simultaneous interrupt sources active, then both will be serviced in the one trigger. Susan |
|
|
|
我建议每个XIF检查合格的支票也谢。
以上来自于百度翻译 以下为原文 I'd suggest qualifying each xIF check with a check of xIE too. |
|
|
|
注意,虽然“用匹配的IE标志来限定每个测试”是一个很好的经验法则,但它是额外的代码,并且只有当您的运行代码正在切换IE标志的状态时才是必要的。如果它总是启用的,则不需要检查它。TXEY通常是在运行程序中唯一能够启用的。猛撞。
以上来自于百度翻译 以下为原文 Note, while the "qualify each test with the matching IE flag" is a good rule of thumb, it's extra code, and only necessary when your running code is switching the state of the IE flag. If it's ALWAYS enabled, there's no need to check it. TXIE is usually the only enable I would touch in a running program. |
|
|
|
我很少需要禁用一个IE标志一旦启用在初始化。如果一个IE标志在运行程序中被禁用,那么只有在IE检查中,IE检查才是ISR。ISR应该是快速的,并且检查IE,当它总是被启用时,会破坏这个目的。有了这样的“每个XIF检查与谢的支票”,因为这是这样做,这是不必要的,当测试总是真实的。
以上来自于百度翻译 以下为原文 I rarely have a need to disable an IE flag once it is enabled in the initialization. If and when an IE flag is disabled in a running program, then and only then I will add the IE check to the ISR. ISR is supposed to be fast and checking IE, when it's ALWAYS enabled, defeats that purpose. Having such "qualifying each xIF check with a check of xIE" as this if(TMR0IE == 1 && TMR0IF == 1) {...} is like doing this unsigned char foo; if (foo >= 0 && foo <= 100) {...} It's unnecessary when the test is always true. |
|
|
|
只有小组成员才能发言,加入小组>>
5184 浏览 9 评论
2005 浏览 8 评论
1932 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3179 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2230 浏览 5 评论
739浏览 1评论
626浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
511浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
637浏览 0评论
535浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-28 10:20 , Processed in 1.213563 second(s), Total 86, Slave 70 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号