Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: Need overview on usage of Quadtimer features on Teensy 4

  1. #1

    Need overview on usage of Quadtimer features on Teensy 4

    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.

  2. #2
    Senior Member
    Join Date
    Apr 2014
    Doesn't answer your question about the Quad timers but if you just need to generate quadrature signals you can have a look here 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.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts