I have a mega32 with a .5 s WDT. It had been working fine and then out of the blue it starts hanging (for a short period of time; i.e. it hangs then goes back to work). This only occurs when the WDT is enabled. When the WDT is disabled I don't have any problems with resets or hangs.
The mega also seems to be resetting itself during this. I used the AVRStudio debugger to try and analize the problem. My watchdog reset function isn't causing the WDT trigger reset, which is why I suspect code hang. But looking at MCUCSR on reset at the top of main() to figure out the source of reset shows MCUCSR to be 0x00. Or am I misunderstanding the meaning of that register?
Additionally, there is a second device which notices when the problem device goes unresponsive. It will notice this before the WDT triggers a reset. However, if the problem were due to a code hang and WDT reset, I would expect the second device to notice the problem when the WDT is disabled; but that isn't the case.
My program is interrupt driven and has an emptly infinite loop in main(). As a test I stuck a WDR call in that loop. The mega32 went much longer without hanging, but still hung.
Any thoughts or ideas? Does anyone know of a code analysis tool for the ATmegas/CodeVision/AVRStudio to analyze how long sections of code run, or where they hang? How might enabling a WDT cause a reset if the WDT isn't doing the resetting?