Hey
The LED should toggel every second, but the LED needs 4s to switch.
unsigned int timerCounter = 0;
void setup() {
//---------------------------------------
//intialize Timer
TIMSK0 = _BV(OCIE0A); // Enable Interrupt TimerCounter0
TCCR0A = _BV(WGM01); // Mode = CTC
TCCR0B = _BV(CS01)|_BV(CS00); // 64 Prescaler
OCR0A = 125; // 0,0001s
sei();
//----------------------------------------
pinMode(13, OUTPUT);
}
void loop() {
}
ISR(SIG_OUTPUT_COMPARE0A)
{
timerCounter++;
if(timerCounter==10000)
{
digitalWrite(13, HIGH); // set the LED on
}
if(timerCounter>=20000)
{
digitalWrite(13, LOW); // set the LED off
timerCounter=0;
}
}
My Calculation is: 1/16000000*64*125=0,00001s
Where is the failure?
Thanks, Nikolausi