Skip to main content
Visitor II
March 24, 2025
Question

STM32G4 HRTIM Swap Mode and Deadtime

  • March 24, 2025
  • 1 reply
  • 565 views

Does it work, and what are the results?

    This topic has been closed for replies.

    1 reply

    Technical Moderator
    March 25, 2025

    Hi @Scotty55 

    First of all, you need to learn how to write a question on the community by following this article: "How to write your question to maximize your chances of finding a solution"

    Regarding the Swap Mode,

    The swap mode in HRTIM is applied by using the SWPD bit in the HRTIM_CR2 register. 

    The procedure is the following: 

    During initialization: Set the PREEN bit to 1 during the initialization of the HRTIM (to prepare the HRTIM for swapping).

    It is important to keep the PREEN bit set to 1 even after the output swapping. It must remain enabled even after the swap: The swap occurs on the update following the toggling of the swap bit.

    During run-time:

    - To Swap Output (0.normal output): If the current output is normal, set the SWPD bit to 1 in the HRTIM_CR2 register (The outputs will be swapped on the following update event).

    - To Return to Normal Output (0.swap output): If the output is currently swapped, set the SWPD bit to 0 in the HRTIM_CR2 register (The outputs will be swapped back to normal on the following update event).

    This process allows for the swapping of the outputs without stopping the timer, ensuring continuous operation.

    You can use this HRTIM example project (and update it according to your needs) for swap mode:

    STM32CubeG4/Projects/NUCLEO-G474RE/Examples/HRTIM/HRTIM_Basic_MultiplePWM at master · STMicroelectronics/STM32CubeG4 · GitHub

     

    Thank you.

    ELABI.1