Teensy 4.1 equivalent of RPi "PIO"?

KarenColumbo

Active member
Dear PJRC people, there's this great Juno DCO project by Jan Knippers, https://github.com/polykit/pico-dco. It relies on PIO (which seems to be a Raspberry-exclusive thing) to deliver a stable "reset" frequency via PWM to a Juno 106 like sawtooth oscillator.

Is there a PIO (see https://hackspace.raspberrypi.com/articles/what-is-programmable-i-o-on-raspberry-pi-pico) equivalent for Teensy 4.1? PIO code seems to run independently from any main routines, so you don't have to juggle any interrupts, they just shift in/out anything you throw into a certain part of the memory.

I know that the T4.1 is a clock monster compared to any RPi Pico MCU, so maybe (we're talking audio range) it's not really all that critical. But what would be the cleanest way of putting out highly stable PWM frequencies out of a T4.1?
 
FlexIO is the closest thing on the Teensy to PIO, but it's not quite as "hands-off". Although if you just want to output PWM signals, there's other dedicated modules for that.
 
FlexIO is the closest thing on the Teensy to PIO, but it's not quite as "hands-off". Although if you just want to output PWM signals, there's other dedicated modules for that.
Thanks! If guess what I really need is a very stable PWM wave that doesn't react to anything that's going on, except the frequency gets updated. It's just a synth, after all, there's not much going on in relation to MHzs of clock, even if I wiggle the pitchbender like mad or LFO the heck out of the current note.

So you say I should get acquainted with timer interrupts to ensure nothing fiddles with my "reset" signal? WHich are those other modules? I read a bit into digitalWrite, analogWrite(Frequency), according to the T4.1 fact sheet.
 
Sounds like analogWriteFrequency(pin, freq) and analogWrite(pin, duty) is enough. This will allow you to create (almost) any frequency. The PWM hardware does all the work, so the waveform doesn't depend on software interrupts. Details here:


You need to use the PWM capable pins, but Teensy 4.x has so many of them! If you want more than 1 independently controlled frequency, be careful to pick pins controlled by different hardware timers. See the "PWM Frequency" section of that page for info about which groups of pins are controlled by the same timer (and would be forced to have the same frequency).
 
Also be aware analogWriteFrequency() can accept a floating point number for the frequency, so you're not limited to integer precision. It will automatically make the closest frequency the hardware can create. All the timers have 16 bit resolution, so you can get frequencies very precisely tuned to musical notes.
 
Thanks for that! It gives me hope :) I'm pretty sure my dear T4.1 is fast enough to handle 16 independent voices via mux/demux?
 
Back
Top