/** * Time base */ #include "time_base.h" #include "global_state.h" #include #include #include /// timestamp counted in units of 100ms volatile uint16_t timestamp_100ms = 0; /// sub-second counter, counts 0-9 then overflows static volatile uint16_t subsec_counter = 0; // 100ms counter ISR(TIMER1_COMPA_vect) { timestamp_100ms++; req_update_display = true; subsec_counter++; if (subsec_counter == 10) { subsec_counter = 0; second_callback_irq(); } } void init_timebase() { // CTC & presc=256 TCCR1B = (1 << WGM12) | (1 << CS12); TIMSK1 = (1 << OCIE1A); // Enable CTC interrupt OCR1A = 6250; // 100ms }