Part Number: TMS320F28335
Hi ,
I have written a code for 28335 DSP . It is designed for a boost converter in which I want to generate PWM for my Mosfet manually using Action Qualifier register . below is my PWM configuration :
void InitEPwm3Example()
{
//PWM frequency 20 KHz
EPwm3Regs.TBPRD = 1875;
EPwm3Regs.TBPHS.half.TBPHS = 0x0000;
EPwm3Regs.TBCTR = 0x0000;
EPwm3Regs.TBCTL.bit.CTRMODE = 3; //TB_COUNT_UPDOWN;
EPwm3Regs.TBCTL.bit.PHSEN = TB_DISABLE;
EPwm3Regs.TBCTL.bit.HSPCLKDIV = 1;
EPwm3Regs.TBCTL.bit.CLKDIV = 0;
// Setup compare
EPwm3Regs.CMPA.half.CMPA = 0;
EPwm3Regs.CMPCTL.bit.SHDWAMODE = 0;
EPwm3Regs.CMPCTL.bit.LOADAMODE = 0;
// Set actions
EPwm3Regs.AQCTLA.bit.CAU = 1;
EPwm3Regs.AQCTLA.bit.CAD = 2;
// EPwm2Regs.AQCTLB.bit.CAU = AQ_CLEAR;
// EPwm2Regs.AQCTLB.bit.CAD = AQ_SET;
// Active high complementary PWMs - setup the deadband
EPwm3Regs.DBCTL.bit.OUT_MODE = 0x3; //Dead band is fully enabled
EPwm3Regs.DBCTL.bit.POLSEL = 0x2; // Active high complementary
EPwm3Regs.DBCTL.bit.IN_MODE = 0x0; //EPWMxA is the source for both Rising Edge delay and Falling Edge delayed signals
EPwm3Regs.DBRED = 75; //1us
EPwm3Regs.DBFED = 75;
// EPwm2_DB_Direction = DB_UP;
//Trip Zone Settings
EALLOW;
EPwm3Regs.TZCTL.all = 0xA; //Force Both epwmxA and ePWMxB to low state when in TZ.
EDIS;
// Interrupt where we will modify the deadband
// EPwm2Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event
// EPwm2Regs.ETSEL.bit.INTEN = 1; // Enable INT
// EPwm2Regs.ETPS.bit.INTPRD = 0x1; // Generate INT on 3rd event
}
I have initialized the PWM using this code :
EALLOW;
EPwm3Regs.TZFRC.bit.OST=0;
EPwm3Regs.TZCLR.bit.OST=1;
EDIS;
This one works and my switch turns on . but when I want to turn off the switch using this code : EPwm3Regs.AQCSFRC.all=1 to set the PWM low, this does not work and the Mosfet becomes short circuit . ( PWM always at high level ) .
What is the reason and could you please help me solve this problem?
(for some reason , I don't want to use TZ registers as my frequency is not constant )