More timer confusion
2011-09-28 by Philippe Habib
As it turned out, I need timer 0 to run PWM on a pin so I have to use timer 1 for my timer tick.
Using what I learned from timer 0, I was hoping it would be easy to generate a 10ms tick using timer 1.
Here is my setup:
TCCR1A = (0 << WGM10) | (0 << WGM11); // Make sure these are low for CTC
TCCR1B |= (0 << WGM12); // CTC mode
TCCR1B |= (1 << CS12); // Use system clock
TCCR1B |= (1 << CS10) | (0 << CS11) | (0 << CS12); // no div, full clock
TIMSK1 = (1 << OCIE1A); // Set int for match on A
OCR1A = 64000; // compare value
// OCR1AH = 0xFF; // MSB
// OCR1AL = 0x00; // LSB
Here is my ISR
ISR(TIMER1_COMPA_vect)
{
PORTD ^= (1 << 6); //Toggle LED
return;
}
Using the system clock, I am getting times in the seconds. Am I doing something totally wrong with my timebase, or something else?
Thank you for any light you can shed on this.