How to control PWM phase?

Status
Not open for further replies.

jwatte

Well-known member
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 :)
 
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?
 
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.
 
OK, thanks! I guess that makes sense, as it allows atomic updates of multiple pins at the same time.
 
Status
Not open for further replies.
Back
Top