Skip to main content
Explorer
September 29, 2025
Question

How to start all channels in a timer simultaneously under STM32Cube HAL

  • September 29, 2025
  • 2 replies
  • 278 views

This should be a simple use case but to my surprise it does not seems obvious how to do it. Say I have 3 PWM channels in the same timer, how do I turn them on simultaneously?

If I do 

  if (HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1) != HAL_OK) Error_Handler();
  if (HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2) != HAL_OK) Error_Handler();
There could be delay between the two steps. Is there a model where I can
1) Enable PWM CH1, 2) Enable PWM CH2, 3) start timer
 
What is the proper way to achieve this?
 
    This topic has been closed for replies.

    2 replies

    Explorer
    September 29, 2025

    Configure timer in Slave mode: Trigger mode
    The counter can start in response to an event on a selected input.
    In the following example, the upcounter starts in response to a rising edge on TI2 input:

    Details in Reference Manual for uCPU

    Super User
    September 30, 2025

    Slave mode is not necessary, you can start the counter (and thus all PWMs simultaneously) simply by setting TIM_CR1.CEN in software, as the last thing, after everything else has been set up. But I don't know how to do it in Cube, I don't use Cube.

    JW