Skip to main content
Jerry Yung
Associate III
July 26, 2019
Question

Deadtime about PWM

  • July 26, 2019
  • 3 replies
  • 2413 views

i config TIM with PWM , and insert deadtime , i found the first deadtime is longer than later , this why behave so ?

0690X000009Z78iQAC.png

This topic has been closed for replies.

3 replies

waclawek.jan
Super User
July 26, 2019

What is exactly the setup (in terms of TIM registers, I don't understand Cube/HAL), and what waveform corresponds to which pin?

JW

Jerry Yung
Associate III
July 29, 2019

pin: CH1N CH1

CCMR: OC1M = 0x06​

CCER: CC1E = 1 ,CC1NE = 1 ,CC1P =0,CC1NP = 1

BDTR: DTG = 0xC8

that's all .

waclawek.jan
Super User
July 29, 2019

If you use PWM mode 1 with CC1P=0 and CC1NP=1, and from reset state set up first CCR1, CCMR1, CCER, ARR, both pins should go high, in timing depending on the order of how these settings are performed, as the counter is not running yet, CNT == 0, and in PWM1mode, while CNT<CCR1, the non-inverted output is active.

In other words, the first two rising edges are most probably artefact from the setup process. You may try to set up everything except CCER, and then enable both channels in a single write of CCER, before starting the counter (CR1.CEN=1). You should then see the first two edges to rise simultaneously, and then the rest of the waveform as expected.

JW

Jerry Yung
Associate III
July 30, 2019

yes, the first two edges rise ​simultaneously,

but I want a deadtime between the firse two edges

waclawek.jan
Super User
July 30, 2019

Try to set CNT to ARR-1 just before enabling the timer.

JW