|Subject:||[avr-gcc-list] Watch Dog Timer problems|
|Date:||Fri, 11 Apr 2008 09:09:08 +1000|
|User-agent:||Mozilla Thunderbird 1.0 (Windows/20041206)|
Problem with WatchDog timer
I had some code which used the Watchdog timer and worked fine. My code is now not operating correctly. I can set up the code so the WatchDog timer is turned off. Then I call a function where it is initialized and wait for the processor to reset.
The code I am using is on a AT90USB1287 with code based on the HOST CDC demo application. My memory sizes look ok and the Stack pointer is around 0x20FF which looks right. I am using 21,114 bytes of program memory and 4679 bytes of RAM.
Here is the code I use to test it// Watchdog timer routines
// These routines are used to test the operation
// Procedure to restart the system via the Watchdog timer
goto Die_Loop; // The Watchdog is on!
// It must be in debug mode
cli(); // Turn off the global interrupt (Timing critical)
wdt_reset(); // Reset it
Wdt_clear_flag(); // Clear the flag
Wdt_change_enable(); // We are going to change the setting
Wdt_enable_1s(); // Wait one second
// Turn all the LEDS on
// Check that the WDT interrupt was not enabled
wdt_reg=WDTCSR; // Read it
if(wdt_reg&(1<<WDIE))Led0_off(); // Turn it off
goto Die_Loop1; // Loop and die
In the Release mode the LEDs all turn on and it waits for one second and then it tries to Reset
I thought it may have been a problem with the Watch Dog timer interrupt being turned on but I check for that by turning off one LED which does not happened.
The process is running after this but it has not done a full reset. I monitor it by loking at messages from the serial port. If I cycle the power it restarts correctly. I cannot reset it with the JTag MkII
If I replaced the call to the die() with a with a
(jmp 0x0000), it works fine.
Here is teh code from the Reset vector to the
and then at 0x280
and then at 0x 03F5 which is the call to main.
+000003F5: 94F8 CLI Global
Thanks for any comments.
|[Prev in Thread]||Current Thread||[Next in Thread]|