STM32F303RE: PWMs utilizing Timers with Phase Shift
Hello,
I am assisting with the firmware development of a dual-active bridge converter and I am trying to create a phase-shifted PWM signal that will control the switches. Creating the phase shift is proving challenging, but I had an idea that I believe, in theory, should work. However, I cannot seem to get the configuration correct to implement it.
I am using the STM32F303RE. Let me explain my strategy:
I am utilizing TIM1 and TIM3. Specifically:
TIM1-CH1 - PWM Signal that goes externally, used as reference (aka not phase shifted)
TIM1-CH2 - PWM Signal that goes externally, used as reference (aka not phase shifted)
TIM1-CH3 - PWM Signal that's internal
TIM8-CH1 - PWM Signal that goes externally, in slave mode
TIM8-CH2 - PWM Signal that goes externally, in slave mode
I would like to make both TIM8's a slave that starts its counter on the falling edge of TIM1-CH3. TIM1-CH3 will be synchorized with TIM1-CH1/2 (in other words, their rising edges will always be the same). I will then change the duty cycle of TIM1-CH3. Since TIM8 is a slave of TIM1-CH3, TIM8 will start its counter and rise on the falling edge of TIM1-CH3. See the visual below to help understand.

I am trying to implement them in the STM32CubeMX/IDE, but it's not working. Here is my CubeMX configuration
TIM1:



TIM8:



In the CubeIDE, I also added the following lines after the initialization:
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_1);
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_2);
HAL_TIMEx_PWMN_Start(&htim1, TIM_CHANNEL_2);
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_3);
HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_1);
HAL_TIMEx_PWMN_Start(&htim8, TIM_CHANNEL_1);
HAL_TIM_PWM_Start(&htim8, TIM_CHANNEL_2);
HAL_TIMEx_PWMN_Start(&htim8, TIM_CHANNEL_2);
TIM1->CCR1 = 80;
TIM1->CCR2 = 80;
TIM1->CCR3 = 10;
TIM8->CCR1 = 80;
TIM8->CCR2 = 80;
Unfortunately, it is not working. TIM1-CH1/2 and TIM8-CH1/2 are in sync with no shaft shift, despite the TIM1->CCR3 = 10 that should shift it by 10 counts.
Can anyone help me figure out what I'm doing wrong?
