Other Parts Discussed in Thread: DESIGNDRIVE
Tool/software: Code Composer Studio
Hi
I am try to use a comparator to produce two trip signals: one from the comparator high and one from comparator low. I use these two signals to connect to Digital compare modules to produce DCAEVT2 and DCBEVT2 digital compare signals. After that, I connect TZ1 and TZ2 to these digital compare signals. TZ1 and TZ2 are set by using EPWM action qualifier. However, i couldn't see the right PWM output.
I will upload the code fragment in here.
digital compare code fragment
//
// configure TRIP4 to high trips from comparator 1
// configure TRIP5 to low trips from comparator 1
//
// Clear everything first
//
EPwmXbarRegs.TRIP4MUX0TO15CFG.all = 0x0000;
EPwmXbarRegs.TRIP4MUX16TO31CFG.all = 0x0000;
EPwmXbarRegs.TRIP5MUX0TO15CFG.all = 0x0000;
EPwmXbarRegs.TRIP5MUX16TO31CFG.all = 0x0000;
//
// Enable Mux for input of CMPSS1H and 1L
//
EPwmXbarRegs.TRIP4MUX0TO15CFG.bit.MUX0 = 0; //cmpss1 CTRIPH
EPwmXbarRegs.TRIP5MUX0TO15CFG.bit.MUX1 = 0; //cmpss1 CTRIPL
// Disable all the muxes first
EPwmXbarRegs.TRIP4MUXENABLE.all = 0x0000;
EPwmXbarRegs.TRIP5MUXENABLE.all = 0x0000;
// Enable Mux4 to TRIP4
// Enable Mux0 to TRIP5
EPwmXbarRegs.TRIP4MUXENABLE.bit.MUX0 = 1;
EPwmXbarRegs.TRIP5MUXENABLE.bit.MUX1 = 1;
// EPwm2 trip 4 DC A low ---> DCAEVT2
EPwm2Regs.DCTRIPSEL.bit.DCALCOMPSEL = 3; // Trip 4 DC A low
EPwm2Regs.TZDCSEL.bit.DCAEVT2 = 4; // DCAL high DCAH don't care
EPwm2Regs.DCACTL.bit.EVT2SRCSEL = 0; // No filter
EPwm2Regs.DCACTL.bit.EVT2FRCSYNCSEL = 1; // Asynchronously
// EPwm2 trip 5 DC B low ---> DCBEVT2
EPwm2Regs.DCTRIPSEL.bit.DCBLCOMPSEL = 4; // Trip 5 DC B low
EPwm2Regs.TZDCSEL.bit.DCBEVT2 = 4; // DCBL high DCBH don't care
EPwm2Regs.DCBCTL.bit.EVT2SRCSEL = 0; // No filter
EPwm2Regs.DCBCTL.bit.EVT2FRCSYNCSEL = 1; // Asynchronously
// EPwm3 trip 4 DC A low ---> DCAEVT2
EPwm3Regs.DCTRIPSEL.bit.DCALCOMPSEL = 3; // Trip 4 DC A low
EPwm3Regs.TZDCSEL.bit.DCAEVT2 = 4; // DCAL high DCAH don't care
EPwm3Regs.DCACTL.bit.EVT2SRCSEL = 0; // No filter
EPwm3Regs.DCACTL.bit.EVT2FRCSYNCSEL = 1; // Asynchronously
// EPwm3 trip 5 DC B low ---> DCBEVT2
EPwm3Regs.DCTRIPSEL.bit.DCBLCOMPSEL = 4; // Trip 5 DC B low
EPwm3Regs.TZDCSEL.bit.DCBEVT2 = 4; // DCBL high DCBH don't care
EPwm3Regs.DCBCTL.bit.EVT2SRCSEL = 0; // No filter
EPwm3Regs.DCBCTL.bit.EVT2FRCSYNCSEL = 1; // Asynchronously
// Connect the digital compare to PWM actions
EPwm2Regs.AQTSRCSEL.bit.T1SEL=1; // DCAEVT2 connect to T1
EPwm2Regs.AQTSRCSEL.bit.T2SEL=3; // DCBEVT2 connect to T2
EPwm3Regs.AQTSRCSEL.bit.T1SEL=1; // DCAEVT2 connect to T1
EPwm3Regs.AQTSRCSEL.bit.T2SEL=3; // DCBEVT2 connect to T2
// Clear any spurious OV trip
EPwm2Regs.TZCLR.bit.DCAEVT2 = 1;
EPwm2Regs.TZCLR.bit.DCBEVT2 = 1;
EPwm3Regs.TZCLR.bit.DCAEVT2 = 1;
EPwm3Regs.TZCLR.bit.DCBEVT2 = 1;
EDIS;
//
// EPWM2 for the phase v
//
//
// Setup TBCLK
//
EPwm2Regs.TBCTL.bit.HSPCLKDIV=1; // divide by 2
EPwm2Regs.TBCTL.bit.CLKDIV=2; // divide by 4 12.5MHz EPWMCLOCK
EPwm2Regs.TBCTL.bit.CTRMODE=0; // up mode
EPwm2Regs.TBCTL.bit.PHSEN=0; // disable phase loading
//
// Enable PWM
//
EPwm2Regs.TBPRD = 62499; // 200Hz PWM
EPwm2Regs.TBPHS.bit.TBPHS= 0; // phase is zero
EPwm2Regs.TBCTR= 0; // clear counter
// EPWM2 dead band
//
EPwm2Regs.DBCTL.bit.OUT_MODE=3; // DBM is fully enabled
EPwm2Regs.DBCTL.bit.POLSEL=2; // Active high complementary
EPwm2Regs.DBCTL.bit.IN_MODE=0; // EPWMA is the source for both falling edge and rising edge delay
EPwm2Regs.DBRED.bit.DBRED=25; // deadtime 2us
EPwm2Regs.DBFED.bit.DBFED=25; // deadtime 2us
//
// EPWM3 for the phase w
//
//
// Setup TBCLK
//
EPwm3Regs.TBCTL.bit.HSPCLKDIV=1; // divide by 2
EPwm3Regs.TBCTL.bit.CLKDIV=2; // divide by 4 100MHz
EPwm3Regs.TBCTL.bit.CTRMODE=0; // up mode
EPwm3Regs.TBCTL.bit.PHSEN=0; // diable phase loading
//
// Enable PWM
//
EPwm3Regs.TBPRD = 62499; // 200Hz
EPwm3Regs.TBPHS.bit.TBPHS= 0; // phase is zero
EPwm3Regs.TBCTR= 0; // clear counter
//
// EPWM3 dead band
//
EPwm3Regs.DBCTL.bit.OUT_MODE=3; // DBM is fully enabled
EPwm3Regs.DBCTL.bit.POLSEL=2; // Active high complementary
EPwm3Regs.DBCTL.bit.IN_MODE=0; // EPWMA is the source for both falling edge and rising edge delay
EPwm3Regs.DBRED.bit.DBRED=25; // deadtime 2us
EPwm3Regs.DBFED.bit.DBFED=25; // deadtime 2us
// PWM action qualifier
EPwm2Regs.AQCTLA2.bit.T1U = 2; // 2A high
EPwm2Regs.AQCTLB2.bit.T1U = 1; // 2B low
EPwm3Regs.AQCTLA2.bit.T1U = 1; // 3A low
EPwm3Regs.AQCTLB2.bit.T1U = 2; // 3B high
EPwm2Regs.AQCTLA2.bit.T2U = 1; // 2A low
EPwm2Regs.AQCTLB2.bit.T2U = 2; // 2B high
EPwm3Regs.AQCTLA2.bit.T2U = 2; // 3A high
EPwm3Regs.AQCTLB2.bit.T2U = 1; // 3B low