STMicroelectronics / STM32CubeH7

STM32Cube MCU Full Package for the STM32H7 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
https://www.st.com/en/embedded-software/stm32cubeh7.html
Other
514 stars 307 forks source link

STM32 HAL Timer - PWM_Config() does not reset the timer channel state. #186

Closed ajitbasarur closed 2 years ago

ajitbasarur commented 3 years ago

Describe the set-up

Bug The function PWM_Config() does not reset the timer channel state to HAL_TIM_CHANNEL_STATE_RESET although it disables the channel.

Describe the bug

How To Reproduce

  1. Following call sequence will reproduce the bug PWM_Config() --> PWM_Start() --> PWM_Config() --> PWM_Start() .. This fails.

Workaround Solution In the application, one can explicitly check the state of each timer channel by using the following code TIM_CHANNEL_STATE_GET(htim, Channel). If the timer channel state is busy, then call the PWM_Stop() function before reconfiguring the timer channel. PWM_Config() --> PWM_Start() --> PWM_Stop() --> PWM_Config() --> PWM_Start(). This works. This workaround should be part of the HAL Timer library.

Proper Bug Fix if PWM_Config() is called, then check the status of PWM output. There are two possible implementations.

Best Regards, Ajit B

ajitbasarur commented 3 years ago

Hi @ALABSTM,

Thanks for looking into the issue. I have noticed that you have included the issue in stm32cube-mcu-fw-dashboard . Shouldn't the issue be included in stm32cube-mcu-hal**-dashboard?

Best Regards, Ajit B

ASELSTM commented 2 years ago

Hi @ajitbasarur,

The PWM_Stop() is necessary to ensure a correct system behavior. Indeed, the configuration can't be updated since the channel is activated. Changes on the fly are not allowed unless the channel is stopped. The driver has been implemented in the way to respect this sequencing. Control and configuration are separately managed to avoid any system misbehavior. Hence, the correct sequence to deploy is :

PWM_Config() --> PWM_Start() --> PWM_Stop() --> PWM_Config() --> PWM_Start() ...

Unfortunately, you request can't be accepted, so please allow me to close this thread. Thank you for you comprehension.

With regards,

mrx23dot commented 9 months ago

But what's the technical limitation to do this? I could just modify the duty register directly.

I have the same issue on F401 HAL.