Need overview on usage of Quadtimer features on Teensy 4

Status
Not open for further replies.

kdharbert

Well-known member
Digital pins are either FlexPWM pins or Quadtimer pins. I have been making smart usage of the Flexpwm pins for executing PFM and signal edge feedback. However, I believe I have a task that is well suited to use of the Quadtimer pins.

I need two pins to deliver 50% duty cycle and be pi/4 out of phase...perfect quadrature. It seems like quadtimer pins are meant both for quadrature encoding and decoding, but I lack a good overview of generalized use cases and functions available. Is there a good link to features available and an overview of what problems those features solve?

At present I just need to set two pins up to be out of phase by pi/4 at a particular frequency. I can do this with an IntervalTimer object and twiddle the pins on an interrupt, but I suspect there's easy hardware support for this that doesn't generate interrupt traffic. I'd appreciate any code fragments to set this up.
 
Doesn't answer your question about the Quad timers but if you just need to generate quadrature signals you can have a look here https://github.com/luni64/EncSim for a corresponding library. It works up to about 1MHz pulse frequency but uses interrupt based generation which might be not efficient enough for your use case.
 
FlexPWM is probably a better choice for generating quadrature waveforms. Each FlexPWM sub-module has 2 feature-rich outputs (A & B) and 1 low-feature output (X). FlexPWM has very nice buffering of writes, so you can commit all your changes to the timer as 1 atomic operation. You can also sync up to 4 sub-modules together, but that shouldn't be necessary since 1 can generate the 2 signals very nicely.

QuadTimer sub-modules have only a single output signal. So to implement quadrature signals, you're immediately looking at using 2 sub-modules sync'd together. It probably can be done, but the hardware isn't nearly as optimized for controlling 2 outputs as FlexPWM.
 
Status
Not open for further replies.
Back
Top