This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28335: ePWM TZFRC does not work properly

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!

  • Hi Rahel,

    Setting the TZFLG[OST] bit to '1' should force your one-shot trip event to occur and set outputs EPWMA and EPWMB low as configured in TZCTL like you describe. Could you check that the TZFLG[OST] bit is still reading a '1' when the when the forced trip occurs (and not somehow showing up as '0')? 

    TZSEL is only for if you have some specific external signal to use as the trip source, but since you are using a software force, you are correct that you do not need to select these. You don't need TZEINT either, unless you want to trigger an interrupt to occur when the trip zone event occurs. What you could do in terms of debugging is perhaps enable an interrupt and then use a variable in your interrupt to track/show if the one-shot trip is being fully recognized. 

    You can omit the 'EPwm1Regs.TZFRC.bit.OST=1;' in your initialization, since this would carry out your Trip Zone software force upon initialization. I would try running the program again with it only being set in your ERROR state. Please let me know if this alters the program output. 

    Regards,

    Allison

  • Hi Allison

    Thank you for your reply. Also, thanks for your clarification regarding TZSEL and TZEINT, that helps a lot!

    I also played around a bit with the code and also read the manual "Configuring Source of Multiple ePWM Trip-Zone Events". There I found that they use EALLOW for the TZCTL registers and when I did that it worked as intended.

    Regards,

    Rahel