cancel
Showing results for 
Search instead for 
Did you mean: 

Obtain a PWM with 3 outputs having 120 degress phase shift (STM32G070CB)

Ogulcan Ariyurek
Associate II

Hi,

I need to obtain the attached behavior at the output pins with minimal MCU cycles.

I also need interrupts at the beginning of each periods, because I need to do different stuff at each period.

I'm using STM32G070CB which has 64MHz clock frequency and one advanced timer.

Thanks in advance.

Cheers,

Ogulcan

4 REPLIES 4

Read Asymmetric PWM mode subchapter of TIM chapter in RM.

JW

Thanks for the reply.

"Asymmetric mode allows two center-aligned PWM signals to be generated with a programmable phase shift."

I need 3 PWM signals, and preferably I want to use TIM15_CH1, TIM16_CH1 and TIM17_CH1 output pins as my hardware is designed accordingly (but we can change the design later on if necessary)

Look at master-slave interconnection. Set the "PWM-generating" timers as slaves and choose a fourth timer which connects to all 3 of them as a "timing master" (I don't know if there is such possibility, check yourself. There may be a different way, where you daisy-chain the timers, it any other topology). Set the "timing" timer TRGO in TIMx_CR2.MMS to one of the Output Compare, set that channel for the required phase for first "generating" timer, set that timer's period but don't enable it, set it up as slave Trigger and wait until it gets enabled automatically. Then change the phase in "timing" timer and repeat for second "generating" timer. Then the third.

JW

Look at master-slave interconnection. Set the "PWM-generating" timers as slaves and choose a fourth timer which connects to all 3 of them as a "timing master" (I don't know if there is such possibility, check yourself. There may be a different way, where you daisy-chain the timers, it any other topology). Set the "timing" timer TRGO in TIMx_CR2.MMS to one of the Output Compare, set that channel for the required phase for first "generating" timer, set that timer's period but don't enable it, set it up as slave Trigger and wait until it gets enabled automatically. Then change the phase in "timing" timer and repeat for second "generating" timer. Then the third.

JW