cancel
Showing results for 
Search instead for 
Did you mean: 

synching HRTIM's TIMA and TIMB

Javier1
Principal

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 */

 

 

 

 

 

 

Available for consulting/freelancing , hit me up in https://github.com/javiBajoCero
1 ACCEPTED SOLUTION

Accepted Solutions
Javier1
Principal

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

Available for consulting/freelancing , hit me up in https://github.com/javiBajoCero

View solution in original post

2 REPLIES 2
Javier1
Principal

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

 

Available for consulting/freelancing , hit me up in https://github.com/javiBajoCero
Javier1
Principal

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

Available for consulting/freelancing , hit me up in https://github.com/javiBajoCero