Making a SD card GPS logger

I was following this tutorial on creating a SD card GPS logger:

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);


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.

Looks like all of that is just a 4ms timer (250Hz) using interrupts… any idea what that’s used for? I don’t see any reference to it in the code anywhere.

@BDub, I think the author meant to use it but it does nothing and I could find any need for it in any of the referenced libraries. I say remove it! :smile:

1 Like

Thanks for the replies.

Removing them. Everything seems to be working as expected.

I’m using an Ultimate GPS breakout from Adafruit and I’m not sure what the deal is with the 1hz, 5hz and 10hz NMEA update.

Should I be setting it depending on the GPS module used?

The ultimate states that it’s 66 channel with 10hz update so I’m assuming I’ll set it to that?

1 Like

@gotnull, give it a shot and see what happens. Now you are at the fun part… experimentation :stuck_out_tongue:

1 Like