Dear Guys!
I am working on multiple LED control.
My topology includes half-bridge LLC for power and time-division multiplexer(TDM) for 5 LED channel.
The frequency for LLC mosfets is 100 khz, and the frequency for TDM mosfet is 40 khz.
The problem is that the signal control for mosfet of LLC is not synchronized counted timer with those of TDM mosfet.
So I would like to question to you:
1. How to set synchronization for multiple channel with different frequencies.
2. How to set phase shift for multiple frequency case
My code and link of my measured signal for creating ePWM is below,
void InitEPwmTimer()
{
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0; // Stop all the TB clocks
EDIS;
// Set 100khz square waveform for half bridge LLC converter
EPwm1Regs.TBPRD = PERIOD; // Set period for ePWM2
// EPwm1Regs.TBPHS.half.TBPHS = 0; // Set Phase register to zero
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Up-down-count mode and start
EPwm1Regs.TBCTL.bit.PHSEN = 0; // Master pwm
EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW;
// EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_IN; // sync flow-through
EPwm1Regs.TBCTL.bit.SYNCOSEL = 1;
//EPwm1Regs.TBPHS = 0; // Set Phase register to zero
EPwm1Regs.TBCTR = 0;
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; // load on CTR=Zero
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // load on CTR=Zero
EPwm1Regs.AQCTLA.all = 0x0006; // set actions for EPWM2A (active high)
EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // enable dead-band
EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC;
EPwm1Regs.DBCTL.bit.IN_MODE = DBA_ALL;
EPwm1Regs.DBRED = 26; // Register the desire dead-time between the high side and low side PWM
EPwm1Regs.DBFED = 26;
// Configs for 5 LED channel (using Time division multiplex)
EPwm4Regs.TBCTL.all = 0; // default status
EPwm4Regs.TBCTL.bit.CLKDIV = 0; // CLKDIV = 1
//EPwm4Regs.TBCTL.bit.HSPCLKDIV = 0; // HSPCLKDIV = 1
EPwm4Regs.TBCTL.bit.CTRMODE = 0; // up count mode
EPwm4Regs.AQCTLA.all = 0x0012; // ZRO = set, PRD = clear
EPwm4Regs.AQCTLB.all = 0x0120; // ZRO = set, PRD = clear
EPwm4Regs.TBPRD = PERIOD*10; // 40KHz - PWM signal
EPwm4Regs.CMPA.half.CMPA = EPwm4Regs.TBPRD/5; // 20% duty cycle first
EPwm4Regs.CMPB = EPwm4Regs.TBPRD*2/5;
EPwm4Regs.DBRED = 15; // Register the desire dead-time between the high side and low side PWM
EPwm4Regs.DBFED = 15;
EPwm5Regs.TBCTL.all = 0; // default status
EPwm5Regs.TBCTL.bit.CLKDIV = 0; // CLKDIV = 1
EPwm5Regs.TBCTL.bit.HSPCLKDIV = 0; // HSPCLKDIV = 1
EPwm5Regs.TBCTL.bit.CTRMODE = 0; // up mode
EPwm5Regs.AQCTLA.all = 0x0012; // ZRO = set, PRD = clear
EPwm5Regs.AQCTLB.all = 0x0120; // ZRO = set, PRD = clear
EPwm5Regs.TBPRD = PERIOD*10; // 1KHz - PWM signal
EPwm5Regs.CMPA.half.CMPA = EPwm5Regs.TBPRD *1/5; // 20% duty cycle first
EPwm5Regs.CMPB = EPwm5Regs.TBPRD *2/5;
EPwm5Regs.DBRED = 15; // Register the desire dead-time between the high side and low side PWM
EPwm5Regs.DBFED = 15;
EPwm6Regs.TBCTL.all = 0; // default status
EPwm6Regs.TBCTL.bit.CLKDIV = 0; // CLKDIV = 1
EPwm6Regs.TBCTL.bit.HSPCLKDIV = 0; // HSPCLKDIV = 1
EPwm6Regs.TBCTL.bit.CTRMODE = 0; // up - down mode
EPwm6Regs.AQCTLA.all = 0x0012; // ZRO = set, PRD = clear
EPwm6Regs.TBPRD = PERIOD*10; // 40KHz - PWM signal
EPwm6Regs.CMPA.half.CMPA = 740; //
//EPwm4Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // enable dead-band
//EPwm4Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC;
//EPwm4Regs.DBCTL.bit.IN_MODE = DBA_ALL;
EPwm6Regs.DBRED = 15; // Register the desire dead-time between the high side and low side PWM
EPwm6Regs.DBFED = 15;
EPwm4Regs.TBCTL.bit.PHSEN = 0;
EPwm4Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO;
EPwm5Regs.TBCTL.bit.PHSEN = 1; // enable phase shift for ePWM2
//EPwm5Regs.TBCTL.bit.SYNCOSEL = 1; // syncin = syncout
EPwm5Regs.TBPHS.half.TBPHS = EPwm5Regs.TBPRD*3/5; // 1/3 phase shift
EPwm6Regs.TBCTL.bit.PHSEN = 1; // enable phase shift for ePWM2
//EPwm5Regs.TBCTL.bit.SYNCOSEL = 1; // syncin = syncout
EPwm6Regs.TBPHS.half.TBPHS = 740; // 1/3 phase shift
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1; // Start all the timers synced
EDIS;
}
Video of measured waveforms
The green signal is the primary side waveform
The blue one is the 40 khz TDM mosfet waveforms
Thanks you for your supports