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

Thread: How to control PWM phase?

  1. #1
    Senior Member
    Join Date
    Dec 2014
    Posts
    246

    How to control PWM phase?

    For controlling two brushless motors out of a Teensy 3.5, I need to use 12 PWM pins, where I can control not just control frequency and duty cycle, but also phase of the PWM output.
    I looked at the PWM documentation: https://www.pjrc.com/teensy/td_pulse.html
    However, it doesn't talk about the phase of the different pins.

    How do I arrange for the appropriate phase and complementary output of the different PWM output pins?

    (I also need 6 input pins for the Hall sensors, but that I can deal with on my own :-)

  2. #2

  3. #3
    Senior Member
    Join Date
    Dec 2014
    Posts
    246
    Great! That in turn tells me I have to use the Flex Timer Module code from the Kinetis headers, and then go look in the Kinetis manual.

    There was a question by lacsap which hasn't been answered yet, so if someone has an answer, I'd also be interested!

    Somehow I need to stop the timer, set new values and restart the timer to define a new duty cycle on the output. Simply setting FTM0_C0V and FTM0_C1V doesn't work. Otherwise the output keeps its initial duty cycle. Does anyone have a clue why?

  4. #4
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,589
    No access to the core code from my actual iPad, but IIRC a write flag has still to be set after updating the registers, so that the new settings are applied for the next timer cycle. Look in pins_teensy.c how it is is done similarly in the analogWrite() function for the PWM output.

  5. #5
    Senior Member
    Join Date
    Dec 2014
    Posts
    246
    OK, thanks! I guess that makes sense, as it allows atomic updates of multiple pins at the same time.

Posting Permissions

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