/* * Time-Keeping helper */ #include #include #include "timer.h" volatile time_t systemTime = 0; void timerInit(void) { // Using 8bit Timer1 TCCR1 |= (1 << CTC1); // CTC Mode TCCR1 |= (1 << CS12) | (1 << CS11) | (1 << CS10); // Prescaler: 64 OCR1A = 250; // Count to 250 TIMSK |= (1 << OCIE1A); // Enable compare match interrupt } ISR(TIMER1_COMPA_vect) { systemTime++; // one millisecond has passed } time_t timerGet(void) { return systemTime; }