完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
有人能解释一下这些工作是如何被数据表搞糊涂的吗?我总是假设如果一个中断被启用并且标志被设置(在我的例子中是通过计时器3滚动),那么ISR就会被调用并中断处理。n读取数据表是说:为了使中断在翻转,必须设置这些位:TMRCON位的TXCON寄存器的TMRCH位的PIE1,PIE2或PIE5寄存器。T,PIC不会向中断提供向量吗?我知道这是一个不太可能的场景,其中一个几乎不可能复制,但是如果我在ISR被调用之前关闭定时器,但是在定时器翻转之后,会发生什么?是否设置了TMR3IF但未调用ISR?或者TMR3即使在定时器已经翻转的情况下也不会被设置吗?有一个错误,其中计时器正好是1秒在日志中,但事件正好发生在16秒,所以怀疑这是否可能是原因。
以上来自于百度翻译 以下为原文 Can someone please clarify how these work as I'm a little confused by the datasheet. I'd always assumed that if an interrupt is enabled and the flag gets set (in my case by timer 3 rolling over) then the ISR would get invoked and the interrupt handled. I'm seeing odd behaviour very occasionally and on reading the datasheet is says: To enable the interrupt on rollover, you must set these bits:Does this mean that even if TMR3IF is set, the PIC won't vector to the interrupt? I know it's an unlikely scenario, and one which will be almost impossible to duplicate, but if I were to turn the timer off before the ISR was called but as/after the timer rolled over, what happens? Does TMR3IF get set but the ISR not invoked? Or does TMR3IF not get set at all even though the timer has rolled over? Got a bug where a timer is exactly 1 second short in the log but the events happen exactly 16 seconds apart so wondering if this could somehow be the cause. |
|
相关推荐
10个回答
|
|
通常,“E”标志允许中断,但是当给定条件发生时,“F”标志将总是被设置。注意,有时模拟器不与某些设备/计时器一起工作。(发生在我身上)
以上来自于百度翻译 以下为原文 Usually, "E" flags ENABLE interrupts, but the "F" flags will ALWAYS get set when the given condition happens. Also note that sometimes the SIMulator does not work with some devices/timers... (happened to me) |
|
|
|
如果你关闭定时器,则不会中断。IE启用IQ。如果在定时器翻转或等于PR时得到设置,则只需在ISR之前和在ISR中清除,如果通过设置GIE,则可以强制。GIE是全局中断控制器,启用中断。所有您启用/禁用中断掩码,高和低。学习数据表多一点。
以上来自于百度翻译 以下为原文 If you turn the timer off then no interrupt will get called. IE enables the irq. IF gets set when the timer rolls over or equals PR, you only need to clear that before and in an isr, you can force IF by setting IF high. GIE is the global interrupt controller , enables interrupts. PEIE These combinations all your to enable/disable interrupts masks, high and low. Study the datasheet a bit more. |
|
|
|
因此,即使IE和IF是真的,如果计时器被禁用,那么ISR就不会被调用?这是唯一解释我所看到的事情,但我正在努力理解如何,即使计时器从手表晶体运行,而其余的PIC运行在64兆赫,我怎么能设法关闭它之间的定时器滚动和ISR被调用。我有一个计时器提供1秒的滴答声。当它滚动时,ISR停止它,加载新的定时器值并重新启动它,然后为主循环设置一个标志来处理。主循环简单地在每次设置该标志时递增计数器。当我完成计时时,我停止计时器并使用TMR3H来确定一秒的分数。我发现,如果我设法停止计时器,正如它应该翻滚,我是第二个短。在计算时,我检查在ISR中设置的标志,如果它被设置,则添加一个,这将允许在主循环中未处理的翻滚。因此,我能看到的第二个简短的唯一原因是如果翻滚不知为什么不调用ISR来设置这个标志,而唯一的ReA。儿子不会发生的是,如果设置定时器关闭,即使在TMR3IE和TMR3IF被设置时也会调用ISR。当发生这种情况时,下面的定时器总是1秒长,所以我假设当我重新启动定时器时,ISR立即被调用,标志被设置,定时器递增。直接离开,而不是在1秒之后。所以也许我需要检查TMR3IF以及在ISR中设置的标志,但是复制这个bug首先是很困难的,因为时间非常紧迫。
以上来自于百度翻译 以下为原文 So, even if IE and IF are true, if the timer is disabled then the ISR won't get called? That is the only thing that explains what I'm seeing but I'm struggling to understand how, even with the timer running from a watch crystal while the rest of the PIC runs at 64MHz, how I can manage to turn the timer off between it rolling over and the ISR being invoked. To explain... I have the timer providing a 1 second tick. When it rolls over, the ISR stops it, loads new timer values and starts it again, then sets a flag for the main loop to process. The main loop simple increments a counter each time this flag is set. When I'm done timing, I stop the timer and use TMR3H to determine fractions of a second. I'm finding that if I manage to stop the timer just as it should be rolling over, I'm a second short. When doing the calculations I check the flag I set in the ISR and add one if it is set, which should allow for a roll-over that isn't handled in the main loop. So, the only reason I can see for being a second short is if the roll-over somehow isn't invoking the ISR to set this flag, and the only reason that wouldn't happen is if turning the timer off prevents the ISR being called even if TMR3IE and TMR3IF are set. When this happens, the following timer is always 1 second long so I'm postulating that when I re-start the timer the ISR is instantly invoked, the flag gets set and the timer incremented straight away rather than after 1 second. So maybe I need to check TMR3IF as well as the flag set in the ISR, but then replicating this bug will be hard enough in the first place due to the incredibly tight timings... |
|
|
|
打开定时器打开和关闭对TMR3IF标志没有影响。我想你所引用的文本是想说清楚的…你必须让计时器继续运行,以便它在第一时间设置TMR3IF,但是一旦它被设置,它将一直保持到你清除它。如果你有TMR3IE和TMR3IF设置,而你没有得到中断,Gie/Pee和优先级比特是什么?
以上来自于百度翻译 以下为原文 Turning the timer on and off has no effect on the TMR3IF flag. I think the text you quoted was trying to say the obvious... you have to have the timer on and running in order for it to ever set TMR3IF in the first place, but once it's set it'll stay on until you clear it. If you have TMR3IE and TMR3IF set and you're not getting the interrupt what about GIE/PIE and the priority bits? |
|
|
|
通常不需要重新加载定时器。你可能需要在“特殊事件触发”模式中使用比较模块,然后使用CCPYIR代替TimeRIIR,因为定时器永远不会翻转。
以上来自于百度翻译 以下为原文 Usually no reload of a timer is required. You possibly should do this with a compare module in "special event trigger" mode. Use the CCP_IR instead of TIMER_IR then, because the timer never will roll over. Attached Image(s) |
|
|
|
杰瑞,很高兴在这里见到你!中断是正常工作的,它似乎只有当我停止计时器接近点,它应该重新加载,我看到一个问题。我没有改变中断优先级,把它留给剑鱼来处理。我不知道中断是否被调用,但是中断中的标志没有被设置,但是它似乎正在滚动。设置所述标志的唯一条件是TMR3IF为真。混淆…
以上来自于百度翻译 以下为原文 Jerry, good to see you over here! The interrupt is working normally, it only seems to be when I stop the timer close to the point it should reload that I'm seeing an issue. I'm not altering interrupt priority, leaving that to Swordfish to deal with. I don't know if the interrupt is getting called or not, however the flag within the interrupt isn't being set yet it appears the timer is rolling over. The only condition to set said flag is for TMR3IF to be true. Confusing... |
|
|
|
你知道,我从来没想过用CCP做这个伟大的电话。它是否修复了我不知道的问题,但是它会使各种代码变得更容易。例如,为了计算一秒钟的分数,我必须用7F的高定时器字节,现在我可以从零计数,所以可以使用值直接。
以上来自于百度翻译 以下为原文 You know, I never thought to use CCP for this - great call. Whether it fixes the issue I don't know, but it will make various bits of code easier. For example, to calculate the fraction of a second I'm having to AND the high timer byte with $7F, I can now count up from zero so can use the value direct. |
|
|
|
“所以,即使IE和IF是真的,如果计时器被禁用,那么ISR就不会被调用了吗?”它会被调用,因为它们是在一起的。定时器在ReleRver或PR.上设置旗标,只要可以启用该标记,就可以手动设置标志,从而导致ISR。
以上来自于百度翻译 以下为原文 "So, even if IE and IF are true, if the timer is disabled then the ISR won't get called?" It will get called, because they are anded together. The timer sets the flag on rollerover or PR. You can set the flag manually as long as it is enabled reguardless of the timer and that causes the isr. |
|
|
|
我需要深入挖掘这一点,因为计时器正在滚动,但ISR没有被调用……有一些想法可能是错误的-它工作正常,直到计时器停止,但我有很多其他事情发生,调用ISR,所以首先要检查的是TI是否MER 3中断实际配置正确。
以上来自于百度翻译 以下为原文 I need to dig deeper in to this as the timer is rolling over but the ISR isn't getting invoked... Got some ideas what may be wrong - it's working OK up until the point the timer is stopped but then I have plenty of other things happening which invoke the ISR so first thing to check is whether the timer 3 interrupt is actually configured properly. |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5304 浏览 9 评论
2069 浏览 8 评论
1972 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3242 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2279 浏览 5 评论
827浏览 1评论
716浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
664浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
716浏览 0评论
615浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-24 08:40 , Processed in 1.126807 second(s), Total 65, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号