You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On the Teensy 2.0++, the timer library calls the interrupt handler twice immediately after starting, before settling down to the specified rate.
Steps To Reproduce Problem
Start the timer and look at when the timer interrupt is called. See the sketch below.
Expected behavior: the timer should wait the specified interval and then call the timer interrupt periodically.
Observed behavior: the timer interrupt is immediately called twice and then it starts working as expected.
Hardware & Software
Board: Teensy 2.0++
Shields / modules used: none
Arduino IDE version: 1.8.19
Teensyduino version (if using Teensy): 1.56
Version info & package name (from Tools > Boards > Board Manager)
Operating system & version: macOS Monterey 12.3..1 on MacBook Air
Note: I opened issue #55 for a timer problem on the Teensy 3.6. This is a different issue on the Teensy 2.0++.
In the oscilloscope trace below, the yellow pulse is when setup() is called. The green pulses are when timerInterrupt() is called.
Expected behavior: a green pulse 100 microseconds after the yellow pulse, followed by green pulses every 100 microseconds.
Observed behavior: two green pulses immediately after the yellow pulse, followed by the correct pulses every 100 microseconds.
The text was updated successfully, but these errors were encountered:
Setting TIFR1 clears the pending timer interrupt, which removes one glitch. Calling Timer1.start() ensures that the timer starts from 0, which removes the other glitch. Both are necessary to get the timer interrupt to fire after the specified delay.
Adding the TIFR1 line to the start() method in TimerOne.h might be a fix.
Description
On the Teensy 2.0++, the timer library calls the interrupt handler twice immediately after starting, before settling down to the specified rate.
Steps To Reproduce Problem
Start the timer and look at when the timer interrupt is called. See the sketch below.
Expected behavior: the timer should wait the specified interval and then call the timer interrupt periodically.
Observed behavior: the timer interrupt is immediately called twice and then it starts working as expected.
Hardware & Software
Board: Teensy 2.0++
Shields / modules used: none
Arduino IDE version: 1.8.19
Teensyduino version (if using Teensy): 1.56
Version info & package name (from Tools > Boards > Board Manager)
Operating system & version: macOS Monterey 12.3..1 on MacBook Air
Note: I opened issue #55 for a timer problem on the Teensy 3.6. This is a different issue on the Teensy 2.0++.
Arduino Sketch
Errors or Incorrect Output
In the oscilloscope trace below, the yellow pulse is when setup() is called. The green pulses are when timerInterrupt() is called.
Expected behavior: a green pulse 100 microseconds after the yellow pulse, followed by green pulses every 100 microseconds.
Observed behavior: two green pulses immediately after the yellow pulse, followed by the correct pulses every 100 microseconds.
The text was updated successfully, but these errors were encountered: