2024-08-07 02:47 AM
Hello all,
it seems that when starting a timer in PWM mode, using TIM_CHANNEL_ALL does not work. Everything works fine as long as I start the channels consecutively, (i.e. TIM_CHANNEL_1, then TIM_CHANNEL_2, etc.) but as soon as I change this to TIM_CHANNEL_ALL, the PWM output stops working. Has anyone else encountered this problem yet or am I doing something wrong?
regards
Herby
Solved! Go to Solution.
2024-08-07 04:59 AM
You're calling HAL_TIM_PWM_Start with TIM_CHANNEL_ALL?
TIM_CHANNEL_ALL is not a valid argument for HAL_TIM_PWM_Start, per the source code. They need to be started one at a time.
/**
* @brief Starts the PWM signal generation.
* @PAram htim TIM handle
* @PAram Channel TIM Channels to be enabled
* This parameter can be one of the following values:
* @arg TIM_CHANNEL_1: TIM Channel 1 selected
* @arg TIM_CHANNEL_2: TIM Channel 2 selected
* @arg TIM_CHANNEL_3: TIM Channel 3 selected
* @arg TIM_CHANNEL_4: TIM Channel 4 selected
* @arg TIM_CHANNEL_5: TIM Channel 5 selected
* @arg TIM_CHANNEL_6: TIM Channel 6 selected
* @retval HAL status
*/
HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
{
2024-08-07 04:59 AM
You're calling HAL_TIM_PWM_Start with TIM_CHANNEL_ALL?
TIM_CHANNEL_ALL is not a valid argument for HAL_TIM_PWM_Start, per the source code. They need to be started one at a time.
/**
* @brief Starts the PWM signal generation.
* @PAram htim TIM handle
* @PAram Channel TIM Channels to be enabled
* This parameter can be one of the following values:
* @arg TIM_CHANNEL_1: TIM Channel 1 selected
* @arg TIM_CHANNEL_2: TIM Channel 2 selected
* @arg TIM_CHANNEL_3: TIM Channel 3 selected
* @arg TIM_CHANNEL_4: TIM Channel 4 selected
* @arg TIM_CHANNEL_5: TIM Channel 5 selected
* @arg TIM_CHANNEL_6: TIM Channel 6 selected
* @retval HAL status
*/
HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *htim, uint32_t Channel)
{
2024-08-07 05:10 AM
Thank you, I was wrongly (read carelessly) assuming this works, being lured into the belief by the naming. A closer look into the HAL manual would have revealed the truth ...
Herbert
2024-08-07 05:52 AM
The assert_param would also not be passing here. IF you've implemented USE_FULL_ASSERT, this would have been caught within the error handler. (If it's not implemented it just silently fails.)