Wrong Output Freq on Teensy 3.2
Opened this issue · 0 comments
zshivers commented
I believe there is a bug in this library, related to the binary search tree logic in setPeriod()
.
The logic never sets clockSelectBits
to 2, where the previous implementation (commented code) can.
Specific case which can cause incorrect frequency output:
#include <TimerOne.h>
void pulse(void);
void setup() {
pinMode(17, OUTPUT);
Timer1.initialize(1e6/92); // 92 Hertz
Timer1.attachInterrupt(pulse);
}
void loop() {
}
// create short pulse every interrupt
void pulse(void) {
digitalWrite(17, LOW);
delay(1);
digitalWrite(17, HIGH);
}
The resulting logic probe capture, showing an output frequency of 185 Hz:
This bug seems not to be present when disabling the binary tree optimized code, and using the original version.