cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F072 PWM One pulse

peit
Associate

Hello

Need help, need to set PWM in a one pulse mode, so that at start timer there would be a low level output for a time equal to value of CCRx, after compare the output would be change to a high level and would remain so after overflow and stopping the counter.

Now I use PWM Mode 2 and active high level (tried PWM Mode 1 and active low level), as a result, after the counter stops, the output goes to low level, as shown on the screenshot:

1.png

 

3 REPLIES 3
TDK
Guru

Set up the timer so the pulse is high when CNT = 0 and low when CNT >= 1 (so CCRx = 1), then adjust ARR for the length of pulse you want. You will have 1 count of delay before the pulse starts.

If you feel a post has answered your question, please click "Accept as Solution".

Do I still need to set the channel as PWM mode for this?

 

In fact, I can't understand why there is a high level before the start timer, and a low level after the counter overflow, i.e. the timer tries to form the next period, but it is stopped and the stop occurs when the output is at a low level.

Yes it needs to be in PWM mode.

 

> In fact, I can't understand why there is a high level before the start timer, and a low level after the counter overflow

Probably because the pin/channel is not fully initialized yet. It gets initialized when you start the channel.

If you feel a post has answered your question, please click "Accept as Solution".