Skip to main content
Associate III
December 18, 2024
Solved

stm32h5xx_hal_tim PWM issue when configured for complimentary channel

 

 

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.
hakeilaBest answer
Associate III
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

 

 

2 replies

waclawek.jan
Super User
December 18, 2024

For PWM on complementary output, use HAL_TIMEx_PWMN_Start().

JW

hakeilaAuthorBest answer
Associate III
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