Skip to main content
Graduate II
February 10, 2025
Solved

synching HRTIM's TIMA and TIMB

  • February 10, 2025
  • 2 replies
  • 1248 views

Trying to make a phase shift PWM for a DAB converter, i managed to do this exact functionality with normal TIM1 (Asynchronous mode), but im very very lost with HRTIM.

Javier1_0-1739181617390.png

 

I am able to produce complementary PWM signals for TIMA1 and TIMA2, and TIMB1 TIMB2.

but no luck synching those TIMA and B with the HRTIM master timer.

I guess i just want to have control over that phase difference, babysteps...

 

Javier1_2-1739181348401.png

 

 

 

 

 

 /* USER CODE BEGIN 2 */
 HAL_HRTIM_SimplePWMStart(&hhrtim1, HRTIM_TIMERINDEX_TIMER_A, HRTIM_OUTPUT_TA1);
 HAL_HRTIM_SimplePWMStart(&hhrtim1, HRTIM_TIMERINDEX_TIMER_A, HRTIM_OUTPUT_TA2);

 HAL_HRTIM_SimplePWMStart(&hhrtim1, HRTIM_TIMERINDEX_TIMER_B, HRTIM_OUTPUT_TB1);
 HAL_HRTIM_SimplePWMStart(&hhrtim1, HRTIM_TIMERINDEX_TIMER_B, HRTIM_OUTPUT_TB2);
 /*
 HAL_HRTIM_WaveformOutputStart(&hhrtim1, HRTIM_OUTPUT_TA1); // Enable the generation of the waveform signal on the designated output
 HAL_HRTIM_WaveformOutputStart(&hhrtim1, HRTIM_OUTPUT_TA2); // Enable the generation of the waveform signal on the designated output

 HAL_HRTIM_WaveformOutputStart(&hhrtim1, HRTIM_OUTPUT_TB1); // Enable the generation of the waveform signal on the designated output
 HAL_HRTIM_WaveformOutputStart(&hhrtim1, HRTIM_OUTPUT_TB2); // Enable the generation of the waveform signal on the designated output

 HAL_HRTIM_WaveformCounterStart(&hhrtim1, HRTIM_TIMERID_TIMER_A); // Start the counter of the Timer A operating in waveform mode
 HAL_HRTIM_WaveformCounterStart(&hhrtim1, HRTIM_TIMERID_TIMER_B); // Start the counter of the Timer B operating in waveform mode
 */
 /* USER CODE END 2 */

 

 

 

 

 

 

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

    As i need to control the phase shift between timers maybe what i need is: (following paghe 34 AN4539 multiphase buck converter)

     

     

     

     

     

    The master operates in continuous mode while the slave timers are in single-shot
    retriggerable mode

     

     

     

     

     

    Javier1_1-1739193250380.png

    Master Timer period= TIMA period = TIMB period

    TIMA and B in up-down mode

    • TIMA reset on Master Compare 1
    • TIMB reset on Master Compare 2
    • TIMACH1 PWM TIMACR1
    • TIMACH2 NPWM + deadtime
    • TIMBCH1 PWM TIMBCR1
    • TIMBCH2 NPWM + deadtime

     

    I was not starting the master timer >D thats why it wasnt working, code here https://github.com/javiBajoCero/getting-started-HRTIM-phase-shift-nucleoG4/tree/master

     

    ezgif-5dfe2d9a0be3cb.gif

    2 replies

    Javier1Author
    Graduate II
    February 10, 2025

    Edit:
    By reading the HRTIM cookbook page 17

     

    /* Start Timer A and Timer D */
     HRTIM1->sMasterRegs.MCR = HRTIM_MCR_TACEN + HRTIM_MCR_TDCEN;

     

     Im able to start both timers at the same time, that makes them be synchroniced.
    Now how do i control the phase shift.

     HAL_HRTIM_WaveformOutputStart(&hhrtim1, HRTIM_OUTPUT_TA1); // Enable the generation of the waveform signal on the designated output
     HAL_HRTIM_WaveformOutputStart(&hhrtim1, HRTIM_OUTPUT_TA2); // Enable the generation of the waveform signal on the designated output
    
     HAL_HRTIM_WaveformOutputStart(&hhrtim1, HRTIM_OUTPUT_TB1); // Enable the generation of the waveform signal on the designated output
     HAL_HRTIM_WaveformOutputStart(&hhrtim1, HRTIM_OUTPUT_TB2); // Enable the generation of the waveform signal on the designated output
    
     hhrtim1.Instance->sMasterRegs.MCR= HRTIM_MCR_TACEN +HRTIM_MCR_TBCEN;

    Javier1_0-1739191512196.png

     

    Javier1AuthorAnswer
    Graduate II
    February 10, 2025

    As i need to control the phase shift between timers maybe what i need is: (following paghe 34 AN4539 multiphase buck converter)

     

     

     

     

     

    The master operates in continuous mode while the slave timers are in single-shot
    retriggerable mode

     

     

     

     

     

    Javier1_1-1739193250380.png

    Master Timer period= TIMA period = TIMB period

    TIMA and B in up-down mode

    • TIMA reset on Master Compare 1
    • TIMB reset on Master Compare 2
    • TIMACH1 PWM TIMACR1
    • TIMACH2 NPWM + deadtime
    • TIMBCH1 PWM TIMBCR1
    • TIMBCH2 NPWM + deadtime

     

    I was not starting the master timer >D thats why it wasnt working, code here https://github.com/javiBajoCero/getting-started-HRTIM-phase-shift-nucleoG4/tree/master

     

    ezgif-5dfe2d9a0be3cb.gif