I am learning C and have the following problem:
I want to use timer interrupt routine. The routine works, the LED switch ON and OFF. In side of the routine I want decrement a counter. The routine is below:
(I declare the count variable as "volatile uint16_t count=0;").
ISR(TIMER1_COMPA_vect) // timer compare interrupt service routine
{
digitalWrite(ledPin, digitalRead(ledPin) ^ 1); // toggle LED pin
count--;
if (count=0)
{
TCCR1B =0;
}
}
I want decrement a counter (count) and stop the timer when it reaches zero, but, the counter doesn't decrement.
Can you please help on solving this problem?
Thanks,
Manuel