STM32F072RBT6 TIM1 Complementary PWM – 20 kHz, 50% Duty and 500 ns Dead Time Not Working as Expected
- 7 replies
- 92 views
Hello ST Community,
I am working with an STM32F072RBT6 NUCLEO board and I am trying to generate
3-phase complementary PWM using TIM1.
My requirement is:
• MCU: STM32F072RBT6
• Board: NUCLEO-F072RB
• Timer: TIM1
• System Clock: 48 MHz
• TIM1 Clock: 48 MHz
• PWM Frequency: 20 kHz
• Duty Cycle: 50%
• Complementary PWM: CH1/CH1N, CH2/CH2N, CH3/CH3N
• Required Dead Time: 500 ns
My TIM1 configuration is:
Prescaler = 0
Counter Mode = Up
ARR = 2399
Clock Division = DIV1
CCR1 = 1200
CCR2 = 1200
CCR3 = 1200
PWM frequency calculation:
PWM = 48 MHz / (PSC + 1) / (ARR + 1)
PWM = 48,000,000 / 1 / 2400
PWM = 20 kHz
For the dead time:
TIM1 clock = 48 MHz
1 timer tick = 20.833 ns
Required dead time = 500 ns
500 ns / 20.833 ns ≈ 24
Therefore I configured:
DeadTime = 24
My output pins are:
TIM1_CH1 -> PA8
TIM1_CH1N -> PB13
TIM1_CH2 -> PA9
TIM1_CH2N -> PB14
TIM1_CH3 -> PA10
TIM1_CH3N -> PB15
The problem is with the complementary outputs.
For example, when monitoring PA8 (CH1) and PB13 (CH1N) on an oscilloscope:
• When PA8 is HIGH, PB13 is LOW.
• When PA8 goes LOW, PB13 goes HIGH.
• However, I am not consistently able to observe the expected 500 ns
dead-time interval at every transition.
• Some transitions appear to have the expected dead time, while other
transitions appear different.
I am also unsure whether my TIM1 BDTR/dead-time configuration is correct
for the STM32F072RBT6.
My relevant configuration is:
sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 1200;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCNPolarity = TIM_OCNPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
sBreakDeadTimeConfig.DeadTime = 24;
sBreakDeadTimeConfig.BreakState = TIM_BREAK_DISABLE;
sBreakDeadTimeConfig.AutomaticOutput =
TIM_AUTOMATICOUTPUT_DISABLE;
I would like to confirm:
1. Is DeadTime = 24 correct for obtaining 500 ns dead time
with a 48 MHz TIM1 clock on STM32F072?
2. Is ARR = 2399 and PSC = 0 the correct configuration for exactly
20 kHz PWM?
3. Is PWM Mode 1 with OCPolarity = HIGH and OCNPolarity = HIGH
correct for complementary PWM?
4. Is there any additional TIM1 BDTR/MOE configuration required on
STM32F072 for CHx/CHxN complementary PWM?
5. Is there any recommended configuration in STM32CubeMX for this
application?
6. Could there be a GPIO Alternate Function or output configuration
issue causing the observed waveform?
I would appreciate any guidance regarding the correct TIM1 configuration
and how to reliably obtain 500 ns dead time on all complementary PWM
transitions.
Thank you.
