Part Number: TMS320F28335
Hi,
I'm fairly new to the C2000 microcontrollers. I have a TMS320F28335 and want to use it to control my AC-DC converter. I struggle with the Trip-Zone Force Register (TZFRC). When an overvoltage or overcurrent is detected, my state machine should go to ERROR state and I want to force my ePWM signals to low. So I use the following code in my main file:
case ERROR: EALLOW; // lock PWM output (force to low - all off) EPwm1Regs.TZFRC.bit.OST=1; //force a one-shot trip event via software (0 = ignore, 1 = trip event and set the TZFLG[OST] bit) EPwm2Regs.TZFRC.bit.OST=1; EPwm3Regs.TZFRC.bit.OST=1; EPwm4Regs.TZFRC.bit.OST=1; EPwm5Regs.TZFRC.bit.OST=1; EPwm6Regs.TZFRC.bit.OST=1; EDIS; STOP; break;
In another file I initialize my ePWM registers as follows:
void PWMInit()
{
//----------------------
// Configuration
//----------------------
Uint16 DT = DEAD_TIME*c_CPUFRQ; // c_CPUFRQ in MHz, Dead_time in us
EALLOW; // Allow to access registers
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0; // Stop all the TB clocks
EDIS; // Lock Registers
// EPWM Module 1 config
EPwm1Regs.TBPRD = MOD_HALF_CYCLE; // Period = 7500 TBCLK counts (PWM period = 100us) @ 150 MHz
EPwm1Regs.TBPHS.half.TBPHS = 0; // Set Phase register to zero
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UP; // Asymmetrical mode
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Master module
EPwm1Regs.TBCTL.bit.PRDLD = TB_SHADOW; // Shadow Register
EPwm1Regs.TBCTL.bit.SYNCOSEL = TB_CTR_ZERO; // Sync down-stream module
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1; // No pre-scaling
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // No pre-scaling
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW;
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; //CC_CTR_ZERO; // Active Counter-Compare A (CMPA) Load From Shadow Select Mode. Load on CTR = Zero (TBCTR = 0x0000).
EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; //CC_CTR_ZERO; // Load on CTR = Zero
// Set up Action Qualifier regs (AQ)
EPwm1Regs.AQCTLA.bit.ZRO = AQ_CLEAR;
EPwm1Regs.AQCTLA.bit.CAU = AQ_SET;
// Set up Dead Band regs (DB)
EPwm1Regs.DBCTL.bit.OUT_MODE = DB_FULL_ENABLE; // Enable Dead-band module
EPwm1Regs.DBCTL.bit.POLSEL = DB_ACTV_HIC; // Active high complementary mode. EPWMxB is inverted
EPwm1Regs.DBCTL.bit.IN_MODE = DBA_ALL;
EPwm1Regs.DBFED = DT; // FED = TBCLKs = 0.1us @ 150 MHz
EPwm1Regs.DBRED = DT; // RED = TBCLKs = 0.1us @ 150 MHz
// Set up Trip Zone regs (TZ)
EPwm1Regs.TZCTL.bit.TZA = TZ_FORCE_LO; // Force to low at trip
EPwm1Regs.TZCTL.bit.TZB = TZ_FORCE_LO; // Force to low at trip
EPwm1Regs.TZFRC.bit.OST=1;
All other registers are initialized alike. However, my signals are not forced to low, I measure 0.4V for them. I also tried to force them high by setting "EPwm1Regs.TZCTL.bit.TZB = TZ_FORCE_HI;", which also results in those 0.4V. So something is clearly not working properly.
If I write "EPwm1Regs.TZCTL.bit.TZA = TZ_FORCE_LO;" (or HI) directly into the main file, I do get 0V (or 3.3V) as expected, so I do know that the transition into ERROR state is working properly. So my question remains why the TZFRC is not working properly? I had a look at the technical reference manual. There would also be the TZSEL and TZEINT registers that I could use. I think in my case I do not need the TZSEL register as I use a software forced trip-zone? But maybe the TZEINT? Where would I put that, with the initialization (before or after the TZCTL lines?) or in the main file?
Also, in the initialization, do I need the last line "EPwm1Regs.TZFRC.bit.OST=1;" or is it enough if I use that in the main file?
Thanks!