cancel
Showing results for 
Search instead for 
Did you mean: 

Retrigger phase-shifted one pulse PWMs in master-slave setup

tigraebe
Visitor

Hello,

 

I am using an STM32H723ZG6U and want to output a limited number of phase-shifted pulses on two pins. To do so I currently use TIM1 and TIM8 with PWM generation.

TIM1 acts as the master timer having channel 1 in 'PWM Generation CH1' as the first output and channel 2 in 'Output Compare No Output' for the phase-shift. TRGO is configured as 'Output Compare (OC2REF)'. 'One Pulse Mode' is checked for this timer.

TIM8 is the slave timer in 'Trigger Mode' with Trigger Source 'ITR0' which connects to TIM1. Channel 1 is configured as 'PWM Generation CH1' for the system's second output. This timer is also in 'One Pulse Mode'.

Apart from that both Counter Settings and PWM Generation channels are configured identically to fit my needs. When starting both PWMs for the first time after controller startup everything works as expected (i.e. PWM on TIM1 sends a number of pulses and then stays quiet, same with a phase-shift to TIM1 with PWM on TIM8). Pictures of the configurations are attached.

My problem is, that I cannot figure out, how to restart the timers properly. Whatever I did so far either leads to PWM from TIM8 not beeing started again or both timers losing synchronity which is crucial for my application.

What I tried so far is starting both timers with HAL_TIM_PWM_Start() again, setting some bits with

__HAL_TIM_CLEAR_FLAG(&htim8, TIM_FLAG_UPDATE);
__HAL_TIM_ENABLE(&htim8);
__HAL_TIM_CLEAR_FLAG(&htim1, TIM_FLAG_UPDATE);
__HAL_TIM_ENABLE(&htim1);

and setting all the timer related registers to the exact values as they were before starting the timers initially. None of the mentioned approaches solved my problem so please enlighten me, how to restart the timers by software on demand.

0 REPLIES 0