44.1kHz or 48kHz timer interrupt

mkoch

Active member
Is it somehow possible to create a 44.1kHz or 48kHz timer interrupt with Teensy 4.0?
The problem is that IntervalTimer.begin does only accept microsecond resolution.
20us --> 50000Hz
21us --> 47619Hz
22us --> 45455Hz
23us --> 43478Hz

Michael
 
IntervalTimer allows float. You're not limited to integer microseconds.

So you can use timer.begin(myfunction, 22.6757) to get 44100 Hz.

Of course it will round off to the nearest number of F_BUS clock cycles, which is 150 MHz when the CPU runs at 600 MHz.
 
IntervalTimer allows float. You're not limited to integer microseconds.

So you can use timer.begin(myfunction, 22.6757) to get 44100 Hz.

Of course it will round off to the nearest number of F_BUS clock cycles, which is 150 MHz when the CPU runs at 600 MHz.

It works. But where is this function documented?

Thanks,
Michael
 
I've updated the comments inside IntervalTimer.h which Arduino IDE 2.x uses for the pop up documentation when you hover your mouse over the functions or IntervalTimer name.
https://github.com/PaulStoffregen/cores/commit/c3d9dda08397f7b973daa53de5b34b317fe63275
Hopefully in the future this will help make the website docs easier to find and give a mention of float support in the popup even with the existing code parses as an integer.

Would be good to add the same info to the IntervalTimer::update function which also accepts floats. You might also consider removing the leftover specialization of the update function (see PR701)
 
Last edited:
Back
Top