2025-02-10 01:56 AM - edited 2025-02-10 02:00 AM
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.
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...
/* 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 */
Solved! Go to Solution.
2025-02-10 05:14 AM - edited 2025-02-10 08:01 AM
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
Master Timer period= TIMA period = TIMB period
TIMA and B in up-down mode
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
2025-02-10 04:45 AM
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;
2025-02-10 05:14 AM - edited 2025-02-10 08:01 AM
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
Master Timer period= TIMA period = TIMB period
TIMA and B in up-down mode
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