#include <stdint.h> #include <avr/io.h> #include <avr/interrupt.h> #include <util/atomic.h> volatile uint16_t ctr; ISR(TIMER1_OVF_vect) { ctr--; } ... int main(void) { uint_16 ctr_copy; ... ctr = 0x0200; start_timer(); do { ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { ctr_copy = ctr; } } while(ctr != 0); // wait ; ... }