Skip to main content
Senior
January 30, 2025
Solved

Proper output config for complementary HRTIM outputs

  • January 30, 2025
  • 3 replies
  • 1283 views

I'm using HRTIM Timer F to create two complementary outputs at TF1 and TF2 with deadtime.  I'm finding conflicting examples of how to set the output configuration of the two outputs.

Which of these code segments is correct?

 

 pOutputCfg.SetSource = HRTIM_OUTPUTSET_MASTERCMP3;
 pOutputCfg.ResetSource = HRTIM_OUTPUTRESET_TIMCMP1;
 if (HAL_HRTIM_WaveformOutputConfig(&hhrtim1, HRTIM_TIMERINDEX_TIMER_F, HRTIM_OUTPUT_TF1, &pOutputCfg) != HAL_OK)
 {
 Error_Handler();
 }

 pOutputCfg.SetSource = HRTIM_OUTPUTRESET_TIMCMP1;
 pOutputCfg.ResetSource = HRTIM_OUTPUTSET_MASTERCMP3;
 if (HAL_HRTIM_WaveformOutputConfig(&hhrtim1, HRTIM_TIMERINDEX_TIMER_F, HRTIM_OUTPUT_TF2, &pOutputCfg) != HAL_OK)
 {
 Error_Handler();
 }

 

 

or:

 

 

 pOutputCfg.SetSource = HRTIM_OUTPUTSET_MASTERCMP3;
 pOutputCfg.ResetSource = HRTIM_OUTPUTRESET_TIMCMP1;
 if (HAL_HRTIM_WaveformOutputConfig(&hhrtim1, HRTIM_TIMERINDEX_TIMER_F, HRTIM_OUTPUT_TF1, &pOutputCfg) != HAL_OK)
 {
 Error_Handler();
 }

 if (HAL_HRTIM_WaveformOutputConfig(&hhrtim1, HRTIM_TIMERINDEX_TIMER_F, HRTIM_OUTPUT_TF2, &pOutputCfg) != HAL_OK)
 {
 Error_Handler();
 }

 

 

 

This topic has been closed for replies.
Best answer by DavidNaviaux

With some search of some sample code, I found that when you have deadtime between TF1 and TF2, TF2 should be initialized with the SetSource and ResetSource set as follows:

 

 pOutputCfg.SetSource = HRTIM_OUTPUTSET_NONE;
 pOutputCfg.ResetSource = HRTIM_OUTPUTRESET_NONE;
 if (HAL_HRTIM_WaveformOutputConfig(&hhrtim1, HRTIM_TIMERINDEX_TIMER_F, HRTIM_OUTPUT_TF2, &pOutputCfg) != HAL_OK)
 {
 Error_Handler();
 }

  

3 replies

ST Technical Moderator
January 30, 2025

Hello @DavidNaviaux 

For your use case the good implementation is: 

 HAL_HRTIM_WaveformTimerConfig WaveformTimerConfig;
 WaveformTimerConfig.DeadTimeInsertion = HRTIM_TIMDEADTIMEINSERTION_ENABLED;
 ...
 HAL_HRTIM_WaveformTimerConfig(&hhrtim1, HRTIM_TIMERINDEX_TIMER_F, &WaveformTimerConfig);
 
 Followed by the deadtime configuration:
 HAL_HRTIM_DeadTimeConfig(...)
 
 pOutputCfg.SetSource = HRTIM_OUTPUTSET_MASTERCMP3;
 pOutputCfg.ResetSource = HRTIM_OUTPUTRESET_TIMCMP1;
 if (HAL_HRTIM_WaveformOutputConfig(&hhrtim1, HRTIM_TIMERINDEX_TIMER_F, HRTIM_OUTPUT_TF1, &pOutputCfg) != HAL_OK)
 {
 Error_Handler();
 }

Please refer to the RM0433(HRTIM section) for more details. 

 

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om
Senior
January 30, 2025

My concern is how to initialize the output of TF2.  Does either of my examples handle that correctly?

 

DavidNaviauxAuthorBest answer
Senior
January 30, 2025

With some search of some sample code, I found that when you have deadtime between TF1 and TF2, TF2 should be initialized with the SetSource and ResetSource set as follows:

 

 pOutputCfg.SetSource = HRTIM_OUTPUTSET_NONE;
 pOutputCfg.ResetSource = HRTIM_OUTPUTRESET_NONE;
 if (HAL_HRTIM_WaveformOutputConfig(&hhrtim1, HRTIM_TIMERINDEX_TIMER_F, HRTIM_OUTPUT_TF2, &pOutputCfg) != HAL_OK)
 {
 Error_Handler();
 }