Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Re:Watchdog and sleep modes

2004-04-27 by Brian Dean

On Mon, Apr 26, 2004 at 08:23:55PM -0700, Larry Barello wrote:

> Yep.  This is the most effective way to do a hard reset...  The
> registers and SRAM shouldn't be affected, but if you are using C the
> startup runtime will clear everything out for you. The hardware
> registers (e.g. I/O & peripherals) will be wiped out.
> 
> You might get away with a bit of assembly code, intercept the reset
> vector (can't help you with how...) check to see the reset source
> and skip the C-runtime init code if it were watchdog.  However,
> there would be a host of issues to resolve: which C variables need
> initializing, and which you want to save, etc.  Not a trivial
> problem.

If you are using GCC, you can place the variable(s) that you want the
runtime init code to leave alone in a section called '.noinit', i.e.:

	int foo __attribute__ ((section (".noinit")));

When declared this way, 'foo' will explicitly not be initialized by
the C runtime startup.  Of course, you should initialize it yourself
after you check the watchdog flag which is a good test to see if you
are executing due to a power-on reset or a watchdog reset.

-Brian
-- 
Brian Dean
http://www.bdmicro.com/

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.