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

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

Re: [avr-gcc-list] Sleep mode


From: Mattias Svensson
Subject: Re: [avr-gcc-list] Sleep mode
Date: Mon, 23 Aug 2004 18:11:37 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030915

address@hidden wrote:

Hello, I want to stop the execution of my program with a sleep mode. Is this
correct??

set_sleep_mode(SLEEP_MODE_IDLE);
         while(1){
while(!bit) { sleep_mode()
                 }
                bit=false;

where bit is a flag modify by an interrupt handler

SIGNAL(SIG_OVERFLOW0){  
static int i=0;
int a=h*7.2;
        i++;
        if (i==a){
                bit=true;
                i=0;
        }
}

The interrupt handler counts interrupts and when the number is correct sets the
bit to resume the execution.

Actually you do not need the flag.
When you call the sleep_mode() function the mcu is put in the sleep mode you have configured. If you set sleep mode to "idle" then any interrupt will resume normal operation. All you have to do is call the sleep_mode() function at a well chosen place in your code.

It is important to configure the device with the correct sleep mode, it should be "idle" in this case.
For information on how to do it, look at the datasheet for your device!

/Mattias S



reply via email to

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