Skip to main content
Graduate
January 30, 2025
Solved

Proper output config for complementary HRTIM outputs

  • January 30, 2025
  • 2 replies
  • 1199 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();
     }

      

    2 replies

    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. 

     

    Graduate
    January 30, 2025

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

     

    DavidNaviauxAuthorAnswer
    Graduate
    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();
     }