cancel
Showing results for 
Search instead for 
Did you mean: 

Timer synchronization still has offset

ST User
Associate III

Hello,

I am trying to synchronize two PWM outputs on an STM32H7: TIM4 channel 2 and TIM8 channel 3N.

To do this I am using the HAL synchronization functions, setting TIM4 up as master with "HAL_TIMEx_MasterConfigSynchronization" and TIM8 with "HAL_TIM_SlaveConfigSynchronization" in TRIGGER mode.

The timer synchronization works: I can see the rising edges of the PWMs are aligned on an o-scope, however there is still a 2.4 us offset between the rising edges of the two timers. Surprisingly the rising edge of the slave timer occurs first.

What is causing this offset, and is there a way to eliminate it?

My first thought is to set both timers up as slaves and have a separate timer as master to trigger them both to start. I am also wondering if this might be some artifact from synchronizing the outputs of a + channel with a - channel.

Any tips would be appreciated, thank you.

3 REPLIES 3

> Surprisingly the rising edge of the slave timer occurs first.

Do you enable the slave timer's counter (by setting TIMx_CR1.CEN)?

JW

I'm using the HAL functions, in this case HAL_TIMEx_PWMN_Start. Looking at the hal function it does not enable the counter if the slave mode is set to trigger. I may try stepping through in the debugger to verify that it is taking that path.

Do you believe that is the correct procedure: don't enable the counter in trigger mode?

I don't use Cube/HAL and don't intend to investigate what its functions do.

The slave timer ought to be enabled by the trigger coming from the master - that's the whole point of the trigger slave mode.

While single-stepping, check if the timers' registers have the expected content. Note, that timers can be stopped or not during the single-step stop, in the respective DBGMCU_APBxFZx register.

JW