cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any application scenario when using HRTIM swap mode?

Element147
Associate

Hi all, I'm currently developing a project with STM32G474RETx. I find on the HRTIM module, there is a function called swap mode (as the figure showed). I'm really curious when this function will be applied, is there any scenario?

Element147_0-1715758082593.png

 

1 REPLY 1
Imen.D
ST Employee

Hello @Element147 ,

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen