完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我有一个PIC18F项目,有一个错误导致MCU挂机。这是一种罕见的错误,每天可能发生一次。看门狗定时器启动并重新启动PIC。我想调试这个问题。我现在意识到,我的方法不是最好的,因为我所做的是在WDT事件上设置一个调试器断点并等待。几小时后,断点被击中了。不幸的是,我不能仅仅从内存内容中找到原因,所以如果程序继续的话,我想分析一下程序流。我能修改一些寄存器的内容,让PIC继续下去,就像WDT没有开机一样吗?
以上来自于百度翻译 以下为原文 I have a PIC18F project with a bug that causes the mcu to hang. It's a rare bug happening maybe once a day. The watchdog timer kicks in and restarts the PIC. I want to debug the issue. I realize now that my approach isn't the best, as what I did is set a debugger breakpoint on the WDT event and wait. After several hours the breakpoint was hit. Unfortunately I haven't been able to find the cause from just the memory contents, so instead I'd like to analyse the program flow if it were to continue. Can I modify some register's contents to allow the PIC to continue as if WDT isn't kicking in? |
|
相关推荐
3个回答
|
|
你的问题是WDT导致了一个不象陷阱或ISR的重置。虽然您可以检测到重置是由WDT引起的,但是您没有调用堆栈或类似程序来帮助您确定发生WDT重置时MCU的状态。您可能能够创建用于保持代码当前状态的持久全局变量(或两个)。比如-在函数“X”中,在ISR“y”中,“在主循环中空闲”等。通过使变量持久化,它不会被运行时代码重置(假设您正在用C编程),并且在WDT重置的“main”的开始有一个测试权限,并使用它来设置断点,可以看到这些持久变量的状态,并开始了解发生了什么。不是100%有效,但是它可以给你一些想法。苏珊
以上来自于百度翻译 以下为原文 The issue you have is that the WDT causes a reset which is not like a trap or ISR. While you can detect the fact that the reset was caused by the WDT, you don't have a call stack or similar to help you determine the state of the MCU when the WDT reset occurred. You might be able to create a persistent global variable (or two) that you use to keep the current state of your code. Something like - In function 'X', In ISR 'y', 'Idling in the main loop' etc. By making the variable persistent, it will not be reset by the runtime code (assuming you are programming in C) and by having a test right at the start of the 'main' for the WDT reset and using that to set a breakpoint, you can see the state of those persistent variables and start to get an idea of what happened. Not 100% effective but it can give you ideas. Susan |
|
|
|
谢谢,真的很有帮助!同样发现问题:当等待设置TMRxIF标志时,它挂起,但是由于另一个问题,计时器可能被意外地禁用。这发生在中断发生时,直接在主循环设置某个内存地址之后。主循环要做的下一件事是禁用中断,但是在此之前,isr有机会弄乱刚刚设置的地址,最终导致对T2CON寄存器(可能还有其他寄存器)的不希望的写入!…
以上来自于百度翻译 以下为原文 Thanks, that's helpful indeed! Found the issue too: it hangs when waiting on a TMRxIF flag to be set, but due to another issue said timer can be unintendedly disabled. That happened when my interrupt occurs, directly after the main loop sets up a certain memory address. The very next thing the main loop does is disable interrupts, but before that the isr has a chance to mess up the address that was just set up, ultimately causing an unwanted write to the T2CON register (and probably others!)... |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
5037 浏览 9 评论
1936 浏览 8 评论
1872 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3089 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2157 浏览 5 评论
600浏览 1评论
465浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
494浏览 0评论
396浏览 0评论
IPECMD命令烧录AVR128DA48芯片,报找不到芯片错误
875浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-9-4 12:23 , Processed in 1.221419 second(s), Total 83, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191