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
_______________________________________________
AVR-chat mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/avr-chat