Skip to main content
Ogulcan Ariyurek
Associate III
April 13, 2022
Question

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

  • April 13, 2022
  • 3 replies
  • 1517 views

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

This topic has been closed for replies.

3 replies

waclawek.jan
Super User
April 13, 2022

Read Asymmetric PWM mode subchapter of TIM chapter in RM.

JW

Ogulcan Ariyurek
Associate III
April 14, 2022

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)

waclawek.jan
Super User
April 14, 2022

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

waclawek.jan
Super User
April 14, 2022

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