2022-11-06 09:28 PM
Hello everyone,
I wish to generate Pulses after a certain delay. I already have generated two Asymmetric PWM waveforms which are phase shifted. Now I wish to trigger another timer in One Pulse Mode. How can I achieve this?
I am not able to figure out how to set or trigger the one pulse mode of the timer. I am new to timer programming in STM controllers.
Solved! Go to Solution.
2022-11-07 01:35 AM
The timer which is in OPM mode is slave. In its TIMx_SMCR.TS select one of the ITRx as incoming trigger signal (TRGI), there's a table in the same chapter indicating, which master timer corresponds to which ITRx value. In TIMx_SMCR.SMS select Trigger mode. This means, that you don't need to set TIMx_CR1.CEN from software, but it will be set automatically whenever the selected trigger input signal goes active.
In master timer, chose, what should be the source of outgoing trigger signal (TRGO), in TIMy_CR2.MMS.
JW
2022-11-06 10:47 PM
Which STM32?
The setup is identical to one of the PWM modes, except you have to set also TIMx_CR1.OPM. To start the timer, set TIMx_CR1.CEN, or use the Slave-mode Controller in Trigger mode (see TIMx_SMCR.SMS).
The one-pulse mode is described in the One-pulse mode subchapter of timer chapter in RM.
JW
2022-11-07 12:06 AM
Hello @Community member ,
Thanks for the prompt reply. I was able to set the One Pulse Mode as described by you.
The STM I'm using is the STM32F767ZI Nucleo-144 board.
I also want to know if I can trigger the One pulse for every interrupt generated by another timer. Is that possible or do I have to provide an external interrupt?
2022-11-07 01:35 AM
The timer which is in OPM mode is slave. In its TIMx_SMCR.TS select one of the ITRx as incoming trigger signal (TRGI), there's a table in the same chapter indicating, which master timer corresponds to which ITRx value. In TIMx_SMCR.SMS select Trigger mode. This means, that you don't need to set TIMx_CR1.CEN from software, but it will be set automatically whenever the selected trigger input signal goes active.
In master timer, chose, what should be the source of outgoing trigger signal (TRGO), in TIMy_CR2.MMS.
JW
2022-11-08 07:46 PM
Hello @Community member ,
Sorry for the late reply but this method worked for me. One final follow up question, can I generate pulses on two different channels? I want to generate one pulse each on two different channels of the timer. Also the delay of each of the pulses will be different from each other. Would I be able to achieve this?
2022-11-09 02:47 AM
One timer has only one counting element, and PWM output edges are at CCRx and ARR. In other words, the output pulses from different channels of one timer share one edge (the one at ARR).
Newer STM32 timers have Asymmetric and Combined modes, where you can generate pulses "freely", at the cost of spending two channels per output. Read the TIM chapter in RM.
JW