I am currently working on a project using arduino Due (Atmel SAM3X8E), which hit a watchdog reset randomly. (sometimes it reset in 10 minutes, sometimes it runs hours then hit the watchdog reset). My watchdog time-out is set fairly long(7 sec.)
The project has grown fairly big now, and I dont have a debugger(also no debugger is available for arduino code)
And unfortunately I have no idea where the program can be stocked.
What would you guys suggest to do in this situation?
====================Update 01:======================
Now I am going to use watchdog interrupt to give me more information when watchdog is triggered. I had some research in internet and wrote following code for the setup. But it does not work...
My expect that when I create a while(1){}, the watchdog will be triggered, and through WDT_handler() I can get some debugging message, which later on I can put maybe more useful debugging information. But in the real case. I did not get any message, so I assume that the WDT_handler was not performed at all.
Could anyone have a look and help me to figure out what the problem is?
watchdog setup:
inline static void startWatchdog()
{
//WDT_Enable(WDT, WDT_MR_WDRSTEN | WATCHDOG_INTERVAL );
uint32_t timeout = 8000 * 256 / 1000; //8000ms = 8s
if (timeout == 0) timeout = 1;
else if (timeout > 0xFFF) timeout = 0xFFF;
timeout = WDT_MR_WDRSTEN | WDT_MR_WDV(timeout) |
WDT_MR_WDD(timeout)|WDT_MR_WDFIEN;
WDT_Enable (WDT, timeout);
/* Configure and enable WDT interrupt. */
NVIC_DisableIRQ(WDT_IRQn);
NVIC_ClearPendingIRQ(WDT_IRQn);
NVIC_SetPriority(WDT_IRQn, 0);
NVIC_EnableIRQ(WDT_IRQn);
}
And I have a watchdog handler
void WDT_Handler(void)
{
/* Clear status bit to acknowledge interrupt by dummy read. */
WDT_GetStatus(WDT);
print("help! in WDT");
}
===========================Update 02:=====================
I found out where the problem is! If I want to use Interrupt handler, I should not use WDT_MR_WDRSTEN. It would reset the processor immediately, that is why the WDT_handler did not run. (I guess)
==========Update 03: ========================
I tried to catch return address from stack pointer inside the WDT_Handler. using following code:
uint32_t returnAddr;
// IRQ handler for WDT
void WDT_Handler()
{
returnAddr = __get_MSP();
Com::printFLN(PSTR("return addr: "),returnAddr);
}
Yes, I got some number: 0x20087F28. And I check the disassembly of my project by using arm-none-eabi-objdump.exe to decode my .elf file. And I could not find any address, which is pointing to this number 0x20087F28
Am I doing something wrong here?