Open 5chufti opened 4 years ago
Yes, I just ran into this problem too. My solution is as follows: In timerOne.h, i changed line 85. TCNT1 = 0; I changed 0 to 1. I think preloading this timer generates an interrupt the same as when an overflow happens like when the timer goes from 0xFFFF to 0x0000. Thus generating an overflow interrupt. So if you change line 85 to TCNT1 = 1; No interrupt will happen. Your timing will be 1 clock tick faster than expected....
I changed the Timer1.start() call to Timer1.resume() in blinkLED() and your sketch seems to be working. I'm testing on a Mega though. Having said that I did have problems with Timer1.start().
Looks like I'm nekrothreading here. Maybe it will help someone.
Description
At least on UNO with latest Arduino IDE and lib git version timer.start() probably not working as seen in sketches developed with older version. after a timer.stop() a timer.start() immediately calls ISR (not delayed by set interval)
(maybe it is just an undocumented sideeffect of recent version that stop() clears the set interval?)
Steps To Reproduce Problem
modified example shows problem: see below
Hardware & Software
Board UNO Arduino IDE version Version info & package name (from Tools > Boards > Board Manager) git version as of 21.Nov.2020 Operating system & version Win7
Arduino Sketch
Errors or Incorrect Output
not blinking, counter increasing much too fast w/o blink