STM32L476 — Stable phase shift between TIM1 and TIM8 for DAB converter
Hi,
I am implementing a Dual Active Bridge (DAB) DC-DC converter on an STM32L476RG Nucleo board. The goal is to generate 8 complementary PWM signals using TIM1 (Bridge 1) and TIM8 (Bridge 2), both at 5 kHz with 50% duty cycle, and to control the power transfer by adjusting the phase shift between the two timers.
The phase shift must be adjustable at runtime (via button, potentiometer, or PID controller) without affecting the 50% duty cycle.
I tried three synchronization approaches, all of which failed:
1. Reset Mode (SMS=100): TIM1 sends a TRGO at the end of each period. TIM8 receives it and resets CNT to 0, which cancels any preloaded phase offset every 200 µs. The phase shift cannot be maintained.
2. Trigger Mode (SMS=110): TIM8 starts on the first TRGO then runs freely. The initial phase is correct but there is no ongoing synchronization, which could cause drift over time.
3. CCR1 as TRGO source (MMS=011): Using CCR1 to time the trigger would shift TIM8's start, but CCR1 simultaneously controls the duty cycle of CH1. Changing it breaks the 50% requirement.
My current solution is to set TIM8->SMCR=0 (free-running) and preload TIM8->CNT with a calculated offset before starting both timers. Since both timers share the same 80 MHz internal clock with identical PSC and ARR, no drift is observed in practice.
My question: is there a proper hardware method on STM32L476 to create a stable and dynamically adjustable phase shift between TIM1 and TIM8, without affecting the 50% duty cycle?
Thank you.
