Reputation: 23
I can generate 2 pwm signals with phase difference between them, but when I stop and restart, TIM2 PWM turn on with %100 Duty Cycle.
I use Internal Triggering System to generate delay between to PWM. 1.PWM → TIM1 CH1 Output Compare No Output → TIM1 CH2 2.PWM → TIM2 CH1
I communicate with STM32 via UART using C# windows form application. For example: If I send 0x50, PWMs are turned on, if I send 0x51, PWMs are turned off.
start code:
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
HAL_TIM_OC_Start(&htim1, TIM_CHANNEL_2);
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1);
stop code:
`HAL_TIM_PWM_Stop(&htim1, TIM_CHANNEL_1);
HAL_TIM_OC_Stop(&htim1, TIM_CHANNEL_2);
HAL_TIM_PWM_Stop(&htim2, TIM_CHANNEL_1);`
Anyone who can help?
Upvotes: 0
Views: 1140
Reputation: 11
I had the same problem when I want to generate two PWM signals shifted by an adjustable delay. I found the answer in this part of the reference manual of the STM32H723/733, STM32H725/735 "43.3.10 Output compare mode". In this part, I have seen :
"The output pin can keep its level (OCXM=0000), be set active (OCxM=0001), be set inactive (OCxM=0010) or can toggle (OCxM=0011) on match."
In my project, made with CubeMX, I have set up "active level on match", but it must be "toggle on match" (TIM_OCMODE_TOGGLE in code for sConfigOC.OCMode).
My hypothesis is that on the first capture of the OC2REF for the slave timer, the output pin stays always high so when we restart the timer we cannot trigger, because the signal is high. I'm not sure if it is the correct understanding, but it works for me !
To generate this type of signal I watched this video from ST : https://www.youtube.com/watch?v=QMAgD9SS5_E
But, they used the mode "Active level on match".
I know you already solved your problem, but I answer here if someone facing the problem ^^
Here a screen from my MX configuration
Regards.
Upvotes: 1