EmbDev.net

Forum: ARM programming with GCC/GNU tools Watchdog on SAM7A3


von Jim K. (ancaritha)


Rate this post
useful
not useful
Hi everyone.  I've also posted this on the AT91 forums (incase anyone 
reads that as well), but as no one has responded I'm posting here as 
well.

I'm having an issue with the configuring the watchdog to a certain mode. 
We have an issue in our system which causes it to log up and the 
watchdog fires, this resetting the system.  This works fine, but I'm 
trying to configure the watchdog to fire an interrupt instead so I can 
break at it and take a look at some stuff to try and figure out what 
exactly is breaking.  I seem to be failing at this though, so I was 
wondering if anyone would be able to point out the mistake that I'm 
making.

// Setup watchdog
AT91C_BASE_WDTC->WDTC_WDMR = 0xCF | (0xCF << 16) | AT91C_WDTC_WDFIEN | 
AT91C_WDTC_WDDBGHLT | AT91C_WDTC_WDIDLEHLT;

// Enable interrupt
AT91F_AIC_ConfigureIt(AT91C_BASE_AIC, AT91C_ID_SYS, 
INTERRUPT_PRIORITY_SEVEN, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, 
InterruptServicer::Interrupt_ID_SYS);

// Enable AIC to catch the interrupt
AT91F_AIC_EnableIt(AT91C_BASE_AIC, AT91C_ID_SYS);


And then inside the ISR:

U32 nWatchdogStatus = AT91C_BASE_WDTC->WDTC_WDSR;
if (nWatchdogStatus)
{
   // put the below line in your ISR where you want the RESET...
   RSTC_CR = RSTC_CR_PROCRST | RSTC_CR_PERRST | RSTC_KEY(0xA5);
}


I know the system interrupt part works as its the same interrupt that 
the PIT timer hits, but the watchdog never seems to enter it.  When the 
watchdog fires the system just hangs, it never hits the if statement. 
If I set up the watchdog to reset the system instead of cause an 
interrupt, it works fine.


Anyone got any ideas as to what I might be doing wrong?  Thanks!

von Jim K. (ancaritha)


Rate this post
useful
not useful
So I determined that if I set a while(1) loop and force the watchdog to 
fire, it properly creates the interrupt and catches it.  However, if 
instead of doing while(1) jump to address 0x0 (which causes the system 
to crash) the watchdog interrupt does not get triggered.

I believe this is what is happening in my code.  Somewhere, a bad 
pointer is being accessed, causing a jump to an invalid location and 
locking up the system.  Does anyone know a good way to look at the 
Program Counter and follow it?  I'm currently using the Watch command 
with GDB insight, watch $PC < 0x8000 (0x8000 is where my code starts), 
but whenever I do that my system seems to grind to a halt.  Stepping 
through my code line by line isn't going to work because the crashes 
aren't consistent and I don't even know where they might be occurring, 
so I need something that is automated that can just run and hopefully 
catch the crash.

Does anyone know a way to do this?

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.