Skip to main content
Associate II
July 1, 2024
Question

Generating 60Hz and 600Hz Trigger Signals with PWM in STM32WB55CGU6TR : Synchronization Issue in Slave Mode

  • July 1, 2024
  • 2 replies
  • 2176 views

I'm working on generating two different trigger signals: one at 60Hz and another at 600Hz, using three PWM signals on three GPIO or timer channels. I attempted to use slave trigger mode for synchronization, but I'm encountering a phase shift in the PWM signals after two or three pulses.

Can you please guide me on the best possible way to achieve this task?

2 replies

ST Employee
July 2, 2024

Hello @pippalla_chakravarthi

The synchronization delay between master and slave timers could take 2 or 3 clock cycles, which might contribute to the phase shift you are observing, but we need more details to be able to help! 

Please share your timers configurations 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Associate II
July 2, 2024

Hi @Sarra.S ,

Below are the timer configurations for slave trigger synchronization. I have also attached the IOC file for your review.

 /* USER CODE BEGIN 2 */
 HAL_TIM_Base_Start(&htim2);
 HAL_TIM_Base_Start(&htim1);

 HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1);
 HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
 HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2);
 HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_3);
 /* USER CODE END 2 */

Timer1 configuration

pippalla_chakravarthi_0-1719927454084.png

 

Timer 2 configuration

image.png

 

 

 

Associate II
July 3, 2024

Hi @Sarra.S ,

Are the provided details sufficient, or do you need more information? Please let me know if you require additional details. This task is very important and urgent for us.

waclawek.jan
Super User
July 2, 2024

Trigger mode in Slave-mode controller does nothing else just sets TIMx_CR1.CEN.

In other words, the key is that slave must have TIMx_CR1.CEN=0 if you want to trigger it, otherwise the trigger is ignored.

I don't use Cube and don't know and don't want to know, if the way how you are clicking it in CubeMX and subsequently use in your program, fulfills this requirement or not. But if not, that's the reason why it does not work as you expect.

JW

Associate II
July 3, 2024

Thanks @waclawek.jan  for reply .

Could you share any sample code for this or direct me to an example? .We are looking to use APIs without directly accessing registers. If that's not possible, we will try the method you mentioned.