CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Variable watchdog resistent (reset resistent)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
faessler



Joined: 28 Nov 2003
Posts: 3

View user's profile Send private message Send e-mail

Variable watchdog resistent (reset resistent)
PostPosted: Mon Aug 09, 2004 2:43 am     Reply with quote

Hello,

it is possible to use a variable after reset or watchdog ?

example:
int testvar;

...

if (restart_cause() == WDT_TIMEOUT)
{
testvar++;
if (testvar == 5)
printf ("Ohh we have now 5 restarts ... ");
}
...

It is possible ?

regards

Oliver
Guest








PostPosted: Mon Aug 09, 2004 5:08 am     Reply with quote

Register file is fully static so you can use it.
Don't forget to clear your variable on power-on reset (take a look on Restart_cause() function).
Ttelmah
Guest







Re: Variable watchdog resistent (reset resistent)
PostPosted: Mon Aug 09, 2004 5:26 am     Reply with quote

faessler wrote:
Hello,

it is possible to use a variable after reset or watchdog ?

example:
int testvar;

...

if (restart_cause() == WDT_TIMEOUT)
{
testvar++;
if (testvar == 5)
printf ("Ohh we have now 5 restarts ... ");
}
...

It is possible ?

regards

Oliver

Yes.
However you have to be careful of the 'self clear' behaviour of the compiler. If (for instance), you have 'zero_ram' set, all memory will be lost on the restart. Similarly, a variable declared as 'static', will also be cleared. Variables declared inside a routine, may well be cleared/overwritten by earlier code.
Hence the only safe variable declaration for this type of operation, is a default global (where the variable is declared outside any function), with no 'zero_ram' declaration.
Also remember to read the 'restart_cause', right near the start of the program. This ensures the flag is correctly cleared, in case something happens early in the code.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group