Skip to main content
Graduate
December 18, 2024
Solved

stm32h5xx_hal_tim PWM issue when configured for complimentary channel

  • December 18, 2024
  • 1 reply
  • 664 views

 

 

Hi,

 

I have configured two PWM channels with complimentary channels on TIM1. I am mainly using the STM32CubeMX for configuration. The MX_TIM1_Init() function has been generated successfully which does use the HAL driver for configuring the PWM channels.

 

However, when I called HAL_TIM_PWM_Start() function to start PWM generation on each of the channel, only the base channels were generated successfully but non of the complimentary ones have been generated.

 

So I had to use the stm32h5xx_ll_tim.h driver that managed to generate all PWM channels successfully.

Here is the working PWM start generation code:

/* Enable outputs OC1, OC1N, OC2, OC2N, OC3 and OC3N */
	LL_TIM_CC_EnableChannel(htim1.Instance, LL_TIM_CHANNEL_CH1 |
											LL_TIM_CHANNEL_CH1N |
											LL_TIM_CHANNEL_CH2 |
											LL_TIM_CHANNEL_CH2N);

	/* Enable counter */
	LL_TIM_EnableCounter(htim1.Instance);

	/* Force update generation */
	LL_TIM_GenerateEvent_UPDATE(htim1.Instance);

 

What is wrong with the tim PWM HAL driver for stm32h5 series?

Regards,

Hani

    This topic has been closed for replies.
    Best answer by hakeila

    Thanks @waclawek.jan,

     

    I haven't tried using this function yet. But my problem has been solved by using the LL PWM drivers interface. However, your solution should be cleaner and I will try it out

     

     

    1 reply

    Super User
    December 18, 2024

    For PWM on complementary output, use HAL_TIMEx_PWMN_Start().

    JW

    hakeilaAuthorAnswer
    Graduate
    December 30, 2024

    Thanks @waclawek.jan,

     

    I haven't tried using this function yet. But my problem has been solved by using the LL PWM drivers interface. However, your solution should be cleaner and I will try it out