avr-chat
[Top][All Lists]
Advanced

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

Re: [avr-chat] Interrupts from assync timer in sleepmode


From: Bjarne Laursen
Subject: Re: [avr-chat] Interrupts from assync timer in sleepmode
Date: Thu, 22 Sep 2005 11:38:52 +0200
User-agent: Mozilla Thunderbird 0.7.3 (Windows/20040803)

Erik Christiansen wrote:

On Thu, Sep 22, 2005 at 08:15:46AM +0200, Bjarne Laursen wrote:
What happens is that sometimes the output-compare-match happens just before the sleep while the interrupt is disabled. Then the processor will go to sleep with the interrupt flag set, and not wake up. (Can anyone confirm that this will happen ?).

Bjarne,

  Page 13 of the ATmega32 datasheet shows example code for exactly this
case. The pending interrupt will then not be able to occur before the
cpu is in sleep mode, so your problem cases would seem to be excluded,
IIUC. (i.e. The interrupt is processed from sleep mode, after check
completion.)

  Surely, the cpu will "not wake up" only if the sei is not executed,
or the interrupt is individually masked?

I think this is the examble:
_SEI(); /* set global interrupt enable */
_SLEEP(); /* enter sleep, waiting for interrupt */
/* note: will enter sleep before any pending interrupt(s) */

Yes, that is how I did it first. When the sleepmode is idle, it works fine.
But when sleepmode is power-save, and the output-compare-match happens in the interrupt-disabled part just before sleep. The mega128 will go into sleep, with interrupt enabled, but not wake until the next output-compare-match. It appears that the match must happen after the sleepmode is entered to wake the mcu from power-save.

-Bjarne Laursen, RoseTechnology A/S





reply via email to

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