cancel
Showing results for 
Search instead for 
Did you mean: 

Starting a second timer on the rising edge of PWM pulse of a 2nd timer in OPM mode

Michael98006
Associate III

I have TIM1 configured in OPM mode to generate N PWM pulses on my STM32H743 chip. I need to start another timer at the start of every PWM period so I can generate a short pulse on a GPIO pin with TIM3 timer in the middle of the "high" pulse of the PWM period generated by TIM1. Is there a way to do this? I couldn't find a way to set up TIM1/TIM3 timers in the master/slave mode to trigger TIM3 on the rising edge of the TIM1 PWM pulse. I was only able to start TIM3 on the falling edge of the PWM pulse (not what I needed).

3 REPLIES 3
Mikhail Z
Senior II

A time diagram would be helpful here to understand what you need.

Here's a time diagram:

0690X000009YhwbQAC.png

On 'H7, you don't need a second timer for this waveform, you can use the Combined PWM mode (read the related subchapter of TIM1/8 chapter in RM) and generate the required pulse as a combination of two PWMs on two channels in TIM1.

But if you insist, you can set some of the unused channels of TIM1 to output compare at some time before the required rising edge of TIM3, eg. 400; you don't need to assign a pin to this channel; set TRGO to this channel in TIM1_CR2.MMS, set TIM3 slave mode controller to trigger (TIM3_SMCR.SMS=0b0110), TRGI to TIM1 (TIM3_SMCR.TS=0b0000), set TIM3 in one-pulse mode, the required output channel set to output compare and PWM, its TIM3_CCRx set to the time difference between required edge and the moment set in TIM1 to TRGO (in this case 500-400=100) and TIM3_ARR to the sum of this time and the required pulse length.

JW