[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-chat] why does ISR not always seem to run on wake from sleep?
From: |
Rolf Pfister |
Subject: |
Re: [avr-chat] why does ISR not always seem to run on wake from sleep? |
Date: |
Tue, 8 Nov 2016 08:58:21 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 |
Am 08.11.2016 um 01:56 schrieb Britton Kerin:
#define BLINK_PB5_LED_FOREVER(period_ms) \
do { \
for ( ; ; ) { \
PORTB |= _BV (PORTB5); \
_delay_ms (period_ms / 2.0); \
PORTB &= ~(_BV (PORTB5)); \
_delay_ms (period_ms / 2.0); \
} \
} while ( 0 );
This do while dont make any sense, with while(0) it will
run only once. while(1) would do it forever.
Anyway the for(;;) will do the loop for ever.
while ( 1 ) {
set_sleep_mode (SLEEP_MODE_IDLE);
sleep_enable ();
sei ();
sleep_cpu ();
sleep_disable ();
cli ();
if ( inry ) {
BLINK_PB5_LED_FOREVER (100.42); // Never seems to happen
}
if ( ! got_pbpci ) {
BLINK_PB5_LED_FOREVER (200.42); // Always happend eventually
}
else {
got_pbpci = 0;
}
}
I think after reaching BLINK_PB5_LED_FOREVER it will never again
go to sleep mode. And interrupts will also not happen because
of the cli().
Rolf