cancel
Showing results for 
Search instead for 
Did you mean: 

how to configure timers in master slave to have a low frequency pwm drives a high frequency pwm

alexandre23
Associate III

Hello, I need to control a high frequency pwm with a low frequency pwm on a F407. I have used the gated method described in RM0090, it mostly works, but since the master pwm control the enable of the counting, the output of the slave timer can be left high or low depending at the exact moment the slave timer update is disabled. I want the slave output channel to be low when the low frequency timer disable it.

I am able to do this attaching an ISR to the low frequency timer, playing with the OCxM bits of CCMRx register, but I want to avoid CPU overhead.

I have also been able to do it without ISR, the master timer driving a DMA stream in M2P mode, works, but use a precious DMA stream, and seems a complicated and overkill solution.

I think there is a way just using master slave link, but haven been able to find it ...

thanks for any help.

Alexandre

1 REPLY 1

> I want the slave output channel to be low when the low frequency timer disable it.

You know how fast slave runs, and they both run from the same primary clock, so it should be easy to set the master to output TRGO pulses to gate slave in integer multiples of the slave's period. In that way you start and stop slave always with the same CNT, and that determines its output.

JW