I was following this tutorial on creating a SD card GPS logger:
http://arduinodev.com/mtk3329-10hz-gps-module-with-arduino/
I managed to get everything compiling properly apart from the following lines of code:
void setup() {
...
// Setup timer2 -- Prescaler/256
TCCR2A &= ~((1<<WGM21) | (1<<WGM20));
TCCR2B &= ~(1<<WGM22);
TCCR2B = (1<<CS22)|(1<<CS21);
ASSR |=(0<<AS2);
// Use normal mode
TCCR2A =0;
//Timer2 Overflow Interrupt Enable
TIMSK2 |= (0<<OCIE2A);
TCNT2=0x6; // counting starts from 6;
TIMSK2 = (1<<TOIE2);
SREG|=1<<SREG_I;
...
}
and right at the end of the sketch:
// Timer2 interrupt routine -
// 1/(160000000/256/(256-6)) = 4ms interval
ISR(TIMER2_OVF_vect) {
TCNT2 = 6;
}
Can someone explain to me what these actually do? They’re the only things that don’t really make sense and don’t compile because for example TCCR2A
is not declared.