avr-libc-dev
[Top][All Lists]
Advanced

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

Re: [avr-libc-dev] Hint For Watchdog Disable on Newer AVRs in the Manual


From: Harald Kipp
Subject: Re: [avr-libc-dev] Hint For Watchdog Disable on Newer AVRs in the Manual
Date: Wed, 18 Jul 2007 19:32:17 +0200
User-agent: Thunderbird 1.5.0.12 (Windows/20070509)

Answering my own questions:

No idea what __init() is intended to do, but it won't help: No initialized stack pointer, no return.

Using any earlier section than .init3 provides another problem: No initialized __zero_reg__, no MCUSR or watchdog clear.

To avoid overriding the mirror variable, I added an attribute to it.

u_char mcusr_mirror __attribute__ ((section (".noinit")));

I'd suggest to add this to the watchdog section of the manual.

If it is required to use .init0 (in my case it is), this should work:

void get_mcusr(void) \
  __attribute__((naked)) \
  __attribute__((section(".init0")));

void get_mcusr(void)
{
   asm volatile ("clr __zero_reg__");
   mcusr_mirror = MCUSR;
   MCUSR = 0;
   wdt_disable();
}

If you discover any other problems in this code, please let me know.


Harald





reply via email to

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