Skip to main content
Explorer II
January 18, 2024
Solved

__HAL_TIM_SetCompare for complementary PWM signals

  • January 18, 2024
  • 2 replies
  • 2742 views

Is there a way to use __HAL_TIM_SetCompare() for negated signals while generating complementary PWM signals?

Any help would be appreciated

 

    This topic has been closed for replies.
    Best answer by waclawek.jan

    The signal on TIMx_CHxN output is the same as on TIMx_CHx output, except inverted and dead time applied.

    So, there is only one TIMx_CCRx register, determining the given channel's pulse width, and that is what __HAL_TIM_SET_COMPARE() (which is a newer name for __HAL_TIM_SetCompare()) sets.

    In other words, there is no separate "pulse" register for the inverted output, so there is also no separate macro to set it.

    JW

    2 replies

    waclawek.jan
    waclawek.janBest answer
    Super User
    January 18, 2024

    The signal on TIMx_CHxN output is the same as on TIMx_CHx output, except inverted and dead time applied.

    So, there is only one TIMx_CCRx register, determining the given channel's pulse width, and that is what __HAL_TIM_SET_COMPARE() (which is a newer name for __HAL_TIM_SetCompare()) sets.

    In other words, there is no separate "pulse" register for the inverted output, so there is also no separate macro to set it.

    JW

    ST Technical Moderator
    January 18, 2024

    Hello @ashmithahr 

    Some examples are provided for complementary signals, you can refer to in cube firmware to activate a complementary PWM. Some macros are generally maintained simply for legacy purpose. Here is a hands on to get used to it Hands-On with STM32 Timers: Dead-time Insertion in Complementary PWM Output (youtube.com)

    To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL