/* Timers are used for having actions performed repeatedly at a fixed interval (Eg every 100ms) They should not be confused with Schedulers, which are for performing an action once at a given point of time in the future Timers are typically low resolution (Compared to Schedulers), with maximum frequency currently being approximately every 10ms */ #include "timers.h" #include "globals.h" void initialiseTimers() { //Configure Timer2 for our low-freq interrupt code. TCCR2B = 0x00; //Disbale Timer2 while we set it up TCNT2 = 131; //Preload timer2 with 100 cycles, leaving 156 till overflow. TIFR2 = 0x00; //Timer2 INT Flag Reg: Clear Timer Overflow Flag TIMSK2 = 0x01; //Timer2 Set Overflow Interrupt enabled. TCCR2A = 0x00; //Timer2 Control Reg A: Wave Gen Mode normal //TCCR2B = ((1 << CS10) | (1 << CS11) | (1 << CS12)); //Timer2 Set Prescaler to 5 (101), 1024 mode. /* Now configure the prescaler to CPU clock divided by 128 */ TCCR2B |= (1<