cancel
Showing results for 
Search instead for 
Did you mean: 

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

pippalla_chakravarthi
Associate III

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?

11 REPLIES 11
Sarra.S
ST Employee

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.

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

 

 

 

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

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.

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.

Hi @Sarra.S

Could you please provide an update on this? It's urgent as we need to plan our product release accordingly.

Hello @pippalla_chakravarthi

Sorry for the delayed answer, I cannot see any issue with your configuration, same clock for both timers, slave and trigger source are set correctly...

I have to reproduce this locally and get back to you ASAP 

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.

I am waiting for the solution as earliest as possible @Sarra.S 

Hello @pippalla_chakravarthi

As discussed, I have the timers running at the frequencies you want, however the offset is still there! 

I have tried to toggle a GPIO pin in an interrupt  that occurs with the update event, to debug the phase shift, however the delay between the rising edge of the master and the TRGO output is (P1=600ns ) far less significant than the offset between master-slave (P0=226us)

Trigger Mode_master- slave delay.png

 This delay is documented in the RM, in the slave mode: trigger mode paragraph: 

SarraS_0-1720774810724.png

However, I will be investigating the acceptable delay values... 

 

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.