Skip to main content
Associate III
March 4, 2025
Question

Phase shifted pulses using pwm

  • March 4, 2025
  • 3 replies
  • 2819 views

Hi, I have a b-l4s5i-iot01a board. I want to generate 2 different pulses with a phase difference from different output channels. I have my desired pulses using TIM15 channel 1 and 2 but I cannot delay one of them. TIM1  and TIM8 pins are not accesible on the discovery kit and I want pulses to have 10ms so I used slave trigger mode but CubeMX says for combined channels you must not use slave mode. Below are my configurations. I use TIM1 as a 10MHz trigger for TIM15.

Stm325_0-1741095067598.png

Stm325_1-1741095081790.png

 

 

3 replies

Javier1
Principal
March 4, 2025

https://community.st.com/t5/stm32cubemx-mcus/how-to-generate-a-phase-shifted-pwm-in-asymmetric-pwm-mode/td-p/248894

What you need to dig deeper is a name: this functionality is called Asymetric mode.

 

 

Or use a mcu with HRTIM then is easy, STM32L4S5VIT6 doesnt have HRTIM

hit me up in https://www.linkedin.com/in/javiermuñoz/
Stm325Author
Associate III
March 4, 2025

First of all thank you. Maybe I did not dig enough but TIM15 doesnt seem to have asymmetric mode, other timers have it but they do not have RCR for multiple pulse creation. Should I try another pulse generation methods to use the asymmetric mode of the other timers?

Stm325Author
Associate III
March 4, 2025

Stm325_0-1741100354959.pngStm325_1-1741100371005.pngStm325_2-1741100392490.pngI tried these configurations in TIM8 CH1N and CH3N, I configured them like this, initialized TIM2(Trigger source) then Started One_Pulses of all 4 channels but there is nothing at the output. 

Stm325_3-1741100404553.png

 

waclawek.jan
Super User
March 4, 2025

If your requirements are a tad bit more complex than trivial, clicking in CubeMX is not likely to produce the desired result.

Maybe you could start with stating your exact requirements, together with a timing diagram (sketch).

JW

 

Stm325Author
Associate III
March 4, 2025

Stm325_0-1741103581857.jpeg

I basically want to generate something like this. I generated it without the phase difference using TIM15 in pwm multiple pulses mode by setting it as a slave and triggering it with a 10Hz timer. I just want to add phase difference to this. I think I used complementary channels of TIM8 because no other channel pins of TIM1 and TIM8 are available on the discovery kit board, therefore using complementary channels TIM8 CH1N and CH3N may not be working.

waclawek.jan
Super User
March 4, 2025

This appears to be trivial, but it is not, and can't think of any simple trick to pull this off using two channels of one timer with no software intervention.

I would perhaps try to output this from two different timers, triggering one from the other; and having triggered the former by the slow-running third timmer.

JW

Javier1
Principal
March 5, 2025

Derailing from the question , but, why do you need 2Mhz burst pulses?
Are you doing radio or LCR measurement?

hit me up in https://www.linkedin.com/in/javiermuñoz/
Stm325Author
Associate III
March 6, 2025

Actually, I was trying to drive some transducers and wanted to test some different pulses and their effects but I decided not to try this method for now. I can give an update if I manage to do it with a single timer on stml4s5. Thank  you all.