Hello,
I would like to use timer 1 to generate a t = 10ms signal (100Hz). I set different registers as I did with timer 2, but the behaviour is very different. Look at my code
void startTimer1B (){
cli(); //stop interrupts
TCCR1A = 0; // set entire TCCR1A register to 0
TCCR1B = 0; // same for TCCR1B
TCCR1C = 0; // same for TCCR1C
TCCR1A |= (1 << COM1B0); // Toggle OC1B on Compare Match dans un premier temps pour tester la durée de chaque seuil
TCCR1A |= (1 << COM1A0);
TCCR1A |= (1 << WGM12); // CTC mode TOP on OCRA ?????
OCR1A = 78;
TCCR1B |= (1 << CS10); // Clock select bit From prescaler (1024)
TCCR1B |= (1 << CS12); // Clock select bit From prescaler (1024)
TIMSK1 |= (1 << OCIE1B); // Timer 1 Interrupt on compare match B
sei(); //allow interrupts
}
With timer 2 the frequency is ok, but with timer 1 the value OCR1A = 78 isn't take into account, and TCNT1 goes from 0 to 0xffff ? So the result is a 0.1 hertz signal !
Do you understand my mistake ?