Generating 60Hz and 600Hz Trigger Signals with PWM in STM32WB55CGU6TR : Synchronization Issue in Slave Mode
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-01 9:45 AM
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?
- Labels:
-
BLE
-
STM32CubeMX
-
STM32WB series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-02 5:40 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-02 6:46 AM
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
Timer 2 configuration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-02 8:40 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-02 11:27 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-02 11:39 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-05 5:29 AM
Hi @Sarra.S
Could you please provide an update on this? It's urgent as we need to plan our product release accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-10 9:31 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-10 11:11 AM
I am waiting for the solution as earliest as possible @Sarra.S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-07-12 2:00 AM
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)
This delay is documented in the RM, in the slave mode: trigger mode paragraph:
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.
