cancel
Showing results for 
Search instead for 
Did you mean: 

Problem on STM32F407 and 411 Discovery boards with TIM_CHANNEL_ALL

herbert
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

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)
{

 

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

3 REPLIES 3
TDK
Guru

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)
{

 

If you feel a post has answered your question, please click "Accept as Solution".
herbert
Associate III

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

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.)

If you feel a post has answered your question, please click "Accept as Solution".