avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] preserve state during watchdog reset


From: Simon Han
Subject: Re: [avr-gcc-list] preserve state during watchdog reset
Date: Tue, 3 Feb 2004 13:07:08 -0800


On Tuesday, February 3, 2004, at 12:43 PM, Gavin Jackson wrote:

-----Original Message-----
From: Simon Han [mailto:address@hidden
Sent: Wednesday, 4 February 2004 9:30 a.m.
To: address@hidden
Subject: [avr-gcc-list] preserve state during watchdog reset


Hi all,
        Does anyone figure out a way to preserve state during watchdog
reset?
        I am using watchdog to monitor for some of my functions.  Before and

after function calls, I do a watchdog reset.  Now the problem is how I
can figure out which function caused the watchdog timeout.  I was
thinking to store this information in EEPROM, but the delay of doing
this is way too high.  Will it be possible to assume certain registers
are not reset?

Any suggestions?
Simon

-----------------------------------------------------------------------

Hi Simon

Store whatever it is you want to remember in the SRAM.

Just remember to either place it in the .noinit section as below:

static int KeepTrack __attribute__ ((section (".noinit")));

so that it's not set to 0x00 at startup or you can declare a 'normal'
static variable and check it's value before the startup code runs
that clears all static variables to 0x00.

To .noinit option is the easiest to do.

Regards
Gavin

Hi Gavin,
Thank you for the help!
One more question. How can I tell between a cold start and a watchdog reset? Placing KeepTrack in .noinit will make KeepTrack arbitrary value when I use it in main().
AVR datasheet suggests using MCUCSR to tell between them.
Now my question is that will avr-libc change this register during initialization?

Thank you again,
Simon



reply via email to

[Prev in Thread] Current Thread [Next in Thread]