/* * clock.c * * Created: 4/3/2024 10:29:19 AM * Author: bsw9xd */ #include "clock.h" void timer_init_ctc() { TCCR1A = 0x00; //WGM10 = 0, WGM11 = 0 (CTC mode when combined with WGM12 in TCCR1B) TCCR1B = (1 << WGM12); TCNT1 = 0; // initialize timer at 0 } void start_timer() { TCNT1 = 0; //OCRN1A = (seconds to wait / (prescaler / f_cpu)) OCR1A = 0x3d09; // we'll only need to delay 1 second if(TIFR1 & (1 << OCF1A)) TIFR1 |= (1 << OCF1A); //discard possible compare match TCCR1B |= (1<