Hi all,
I am a new and I hope this is the right section to ask for help.
I wrote this simple sketch just to test timer and interrupt.
# define LED 13
void setup()
{
pinMode(LED, OUTPUT);
cli();
TCCR1A = 0x42; // CTC mode
TCCR1B = 0x01;
OCR1A = 65530; // Set compared value
TIMSK1 = 0; // Reset Timer/Counter0 Interrupt Mask Register
TIMSK1 |= (1 << OCIE1A); // Enable Output Compare Match A Interrupt
sei(); // Enable interrupts once registers have been update
}
void loop()
{
for(;;);
}
ISR(TIMER1_COMPA_vect) // Interrupt service run when Timer/Counter1 reaches OCR1A
{
digitalWrite(LED, !digitalRead(LED));
}
It works, the LED blinks fast. But if I change the register TCCR1B with the value 0x03 (prescaler x64, but it's the same with 256 or 1024) the LED is ALWAYS on! Can anyone help me please? Thanks a lot!
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.