I am learning AVR programming using a book named" Make: AVR programming". I was trying to understand Timer peripheral. What following program does is toggling a pin at a certain interval using interrupt
#include <avr/io.h>
#include <avr/interrupt.h>
// initialize timer, interrupt and variable
void timer1_init()
{
// set up timer with prescaler = 64 and CTC mode
TCCR1B |= (1 << WGM12)|(1 << CS11)|(1 << CS10);
TIMSK1 |= (1 << OCIE1B); // Output Compare B Match Interrupt Enable
// initialize counter
TCNT1 = 0;
// initialize compare value
OCR1B = 7812;
sei();
}
ISR(TIMER1_COMPB_vect) {
PORTC ^= (1 << 0);
}
int main(void)
{
// connect led to pin PC0
DDRC = 0XFF;
// initialize timer
timer1_init();
// loop forever
while(1)
{
}
}
But it's not toggling the pin, Why?