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.

TMS320F28027: Complementary PWM using Digital Power Library Template

Part Number: TMS320F28027
Other Parts Discussed in Thread: C2000WARE

Dear All,

I am trying to generate complementary PMW using digital power template /library. However, the EPWMB always shows high.

I am attaching the template file, asm.and related c code.

The main code is 

//----------------------------------------------------------------------------------
//	FILE:			ProjectName-Main.C
//
//	Description:	Sample Template file to edit
//					The file drives duty on PWM1A using C28x
//					These can be deleted and modifed by the user
//					C28x ISR is triggered by the PWM 1 interrupt  
//
//	Version: 		2.0
//
//  Target:  		TMS320F2802x(PiccoloA), 
//
//----------------------------------------------------------------------------------
//  Copyright Texas Instruments © 2004-2010
//----------------------------------------------------------------------------------
//  Revision History:
//----------------------------------------------------------------------------------
//  Date	  | Description / Status
//----------------------------------------------------------------------------------
// October 2010  - Sample template project with DPLib v3 (MB)
//----------------------------------------------------------------------------------
//
// PLEASE READ - Useful notes about this Project

// Although this project is made up of several files, the most important ones are:
//	 "{ProjectName}-Main.C"	- this file
//		- Application Initialization, Peripheral config,
//		- Application management
//		- Slower background code loops and Task scheduling
//	 "{ProjectName}-DevInit_F28xxx.C
//		- Device Initialization, e.g. Clock, PLL, WD, GPIO mapping
//		- Peripheral clock enables
//		- DevInit file will differ per each F28xxx device series, e.g. F280x, F2833x,
//	 "{ProjectName}-DPL-ISR.asm
//		- Assembly level library Macros and any cycle critical functions are found here
//	 "{ProjectName}-DPL-CLA.asm"
//		- Init code for DPlib CLA Macros run by C28x
//		- CLA Task code
//	 "{ProjectName}-Settings.h"
//		- Global defines (settings) project selections are found here
//		- This file is referenced by both C and ASM files.
//	 "{ProjectName}-CLAShared.h.h"
//		- Variable defines and header includes that are shared b/w CLA and C28x 
//
// Code is made up of sections, e.g. "FUNCTION PROTOTYPES", "VARIABLE DECLARATIONS" ,..etc
//	each section has FRAMEWORK and USER areas.
//  FRAMEWORK areas provide useful ready made "infrastructure" code which for the most part
//	does not need modification, e.g. Task scheduling, ISR call, GUI interface support,...etc
//  USER areas have functional example code which can be modified by USER to fit their appl.
//
// Code can be compiled with various build options (Incremental Builds IBx), these
//  options are selected in file "{ProjectName}-Settings.h".  Note: "Rebuild All" compile
//  tool bar button must be used if this file is modified.
//----------------------------------------------------------------------------------
#include "ProjectName-Settings.h"
#include "PeripheralHeaderIncludes.h"
#include "DSP2802x_EPWM_defines.h"		
		
#include "DPlib.h"	
#include "IQmathLib.h"

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// FUNCTION PROTOTYPES
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// Add protoypes of functions being used in the project here 
void DeviceInit(void);
#ifdef FLASH		
	void InitFlash();
#endif
void MemCopy();

//-------------------------------- DPLIB --------------------------------------------
//void PWM_1ch_CNF(int16 n, int16 period, int16 mode, int16 phase); For one channel only (A)
void PWM_ComplPairDB_CNF(int16 n, int16 period, int16 mode, int16 phase);// for one channel A,B (Complementary)
void PWM_ComplPairDB_UpdateDB(int16 n,int16 dbRed, int16 dbFed);
void ADC_SOC_CNF(int ChSel[], int Trigsel[], int ACQPS[], int IntChSel, int mode);

// -------------------------------- FRAMEWORK --------------------------------------
// State Machine function prototypes
//----------------------------------------------------------------------------------
// Alpha states
void A0(void);	//state A0
void B0(void);	//state B0
void C0(void);	//state C0

// A branch states
void A1(void);	//state A1
void A2(void);	//state A2
void A3(void);	//state A3
void A4(void);	//state A4

// B branch states
void B1(void);	//state B1
void B2(void);	//state B2
void B3(void);	//state B3
void B4(void);	//state B4

// C branch states
void C1(void);	//state C1
void C2(void);	//state C2
void C3(void);	//state C3
void C4(void);	//state C4

// Variable declarations
void (*Alpha_State_Ptr)(void);	// Base States pointer
void (*A_Task_Ptr)(void);		// State pointer A branch
void (*B_Task_Ptr)(void);		// State pointer B branch
void (*C_Task_Ptr)(void);		// State pointer C branch
//----------------------------------------------------------------------------------

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// VARIABLE DECLARATIONS - GENERAL
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

// -------------------------------- FRAMEWORK --------------------------------------

int16	VTimer0[4];					// Virtual Timers slaved off CPU Timer 0
int16	VTimer1[4];					// Virtual Timers slaved off CPU Timer 1
int16	VTimer2[4];					// Virtual Timers slaved off CPU Timer 2

// Used for running BackGround in flash, and ISR in RAM
extern Uint16 *RamfuncsLoadStart, *RamfuncsLoadEnd, *RamfuncsRunStart;
// Used for copying CLA code from load location to RUN location 
extern Uint16 Cla1funcsLoadStart, Cla1funcsLoadEnd, Cla1funcsRunStart;

// Used for ADC Configuration 
int 	ChSel[16] =   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int		TrigSel[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
int     ACQPS[16] =   {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};

// Used to indirectly access all EPWM modules
volatile struct EPWM_REGS *ePWM[] = 
 				  { &EPwm1Regs,			//intentional: (ePWM[0] not used)
				  	&EPwm1Regs,
					&EPwm2Regs,
					&EPwm3Regs,
					&EPwm4Regs,
				  };

// Used to indirectly access all Comparator modules
volatile struct COMP_REGS *Comp[] = 
 				  { &Comp1Regs,			//intentional: (Comp[0] not used)
					&Comp1Regs,				  
					&Comp2Regs,
				  };
// ---------------------------------- USER -----------------------------------------
// ---------------------------- DPLIB Net Pointers ---------------------------------
// Declare net pointers that are used to connect the DP Lib Macros  here 

// PWMDRV_1ch
//extern volatile long *PWMDRV_1ch_Duty1;		// instance #1, EPWM1
extern volatile long *PWMDRV_ComplPairDB_Duty1;

extern volatile long *CNTL_2P2Z_Ref1;
extern volatile long *CNTL_2P2Z_Fdbk1;
extern volatile long *CNTL_2P2Z_Out1;
extern volatile long *CNTL_2P2Z_Coef1;

// ---------------------------- DPLIB Variables ---------------------------------
// Declare the net variables being used by the DP Lib Macro here 

volatile long Duty1;
volatile long Net2;


/* Digital Power (DP) Library Initialization */
//DPL_Init(); // Initialize DP Library


//Feedback node connections

//ADCDRV_1ch_R1t0= &Net2;
//CNTL_2P2Z_Fdbk1= &Net2;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// VARIABLE DECLARATIONS - CCS WatchWindow / GUI support
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

// -------------------------------- FRAMEWORK --------------------------------------

//GUI support variables
// sets a limit on the amount of external GUI controls - increase as necessary
int16 	*varSetTxtList[16];					//16 textbox controlled variables
int16 	*varSetBtnList[16];					//16 button controlled variables
int16 	*varSetSldrList[16];				//16 slider controlled variables
int16 	*varGetList[16];					//16 variables sendable to GUI
int16 	*arrayGetList[16];					//16 arrays sendable to GUI	
int16  LedBlinkCnt;

// ---------------------------------- USER -----------------------------------------

// Monitor ("Get")						// Display as:

// Configure ("Set")

// History arrays are used for Running Average calculation (boxcar filter)
// Used for CCS display and GUI only, not part of control loop processing

//Scaling Constants (values found via spreadsheet; exact value calibrated per board)

// Variables for background support only (no need to access)
int16	i;								// common use incrementer
Uint32	HistPtr, temp_Scratch; 			// Temp here means Temporary

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// MAIN CODE - starts here
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
void main(void)
{
//=================================================================================
//	INITIALISATION - General
//=================================================================================

	// The DeviceInit() configures the clocks and pin mux registers 
	// The function is declared in {ProjectName}-DevInit_F2803/2x.c,
	// Please ensure/edit that all the desired components pin muxes 
	// are configured properly that clocks for the peripherals used
	// are enabled, for example the individual PWM clock must be enabled 
	// along with the Time Base Clock 

	DeviceInit();	// Device Life support & GPIO

//-------------------------------- FRAMEWORK --------------------------------------

// Only used if running from FLASH
// Note that the variable FLASH is defined by the compiler with -d FLASH

#ifdef FLASH		
// Copy time critical code and Flash setup code to RAM
// The  RamfuncsLoadStart, RamfuncsLoadEnd, and RamfuncsRunStart
// symbols are created by the linker. Refer to the linker files. 
	MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);

// Call Flash Initialization to setup flash waitstates
// This function must reside in RAM
	InitFlash();	// Call the flash wrapper init function
#endif //(FLASH)


// Timing sync for background loops
// Timer period definitions found in PeripheralHeaderIncludes.h
	CpuTimer0Regs.PRD.all =  mSec1;		// A tasks
	CpuTimer1Regs.PRD.all =  mSec10;	// B tasks
	CpuTimer2Regs.PRD.all =  mSec100;	// C tasks

// Tasks State-machine init
	Alpha_State_Ptr = &A0;
	A_Task_Ptr = &A1;
	B_Task_Ptr = &B1;
	C_Task_Ptr = &C1;

	VTimer0[0] = 0;	
	VTimer1[0] = 0;
	VTimer2[0] = 0;
	LedBlinkCnt = 5;

// ---------------------------------- USER -----------------------------------------
//  put common initialization/variable definitions here


//===============================================================================
//	INITIALISATION - GUI connections
//=================================================================================
// Use this section only if you plan to "Instrument" your application using the 
// Microsoft C# freeware GUI Template provided by TI
/*
	//"Set" variables
	//---------------------------------------
	// assign GUI variable Textboxes to desired "setable" parameter addresses
	varSetTxtList[0] = &Gui_TxtListVar;
	varSetTxtList[1] = &Gui_TxtListVar;
	varSetTxtList[2] = &Gui_TxtListVar;
	varSetTxtList[3] = &Gui_TxtListVar;
	varSetTxtList[4] = &Gui_TxtListVar;
	varSetTxtList[5] = &Gui_TxtListVar;
	varSetTxtList[6] = &Gui_TxtListVar;
	varSetTxtList[7] = &Gui_TxtListVar;
	varSetTxtList[8] = &Gui_TxtListVar;
	varSetTxtList[9] = &Gui_TxtListVar;
	varSetTxtList[10] = &Gui_TxtListVar;
	varSetTxtList[11] = &Gui_TxtListVar;

	// assign GUI Buttons to desired flag addresses
	varSetBtnList[0] = &Gui_BtnListVar;
    varSetBtnList[1] = &Gui_BtnListVar;
	varSetBtnList[2] = &Gui_BtnListVar;
	varSetBtnList[3] = &Gui_BtnListVar;
	varSetBtnList[4] = &Gui_BtnListVar;

	// assign GUI Sliders to desired "setable" parameter addresses
	varSetSldrList[0] = &Gui_SldrListVar;
	varSetSldrList[1] = &Gui_SldrListVar;
	varSetSldrList[2] = &Gui_SldrListVar;
	varSetSldrList[3] = &Gui_SldrListVar;
	varSetSldrList[4] = &Gui_SldrListVar;

	//"Get" variables
	//---------------------------------------
	// assign a GUI "getable" parameter address
	varGetList[0] = &Gui_GetListVar;
	varGetList[1] = &Gui_GetListVar;
	varGetList[2] = &Gui_GetListVar;
	varGetList[3] = &Gui_GetListVar;
	varGetList[4] = &Gui_GetListVar;
	varGetList[5] = &Gui_GetListVar;
	varGetList[6] = &Gui_GetListVar;
	varGetList[7] = &Gui_GetListVar;
	varGetList[8] = &Gui_GetListVar;
	varGetList[9] = &Gui_GetListVar;
	varGetList[10] = &Gui_GetListVar;
	varGetList[11] = &Gui_GetListVar;
	varGetList[12] = &Gui_GetListVar;
	varGetList[13] = &Gui_GetListVar;
	varGetList[14] = &Gui_GetListVar;
	varGetList[15] = &Gui_GetListVar;

	// assign a GUI "getable" parameter array address
	arrayGetList[0] = &DBUFF1;  	//only need to set initial position of array,
	arrayGetList[1] = &DBUFF2;		//  program will run through it accordingly
	arrayGetList[2] = &DBUFF3;
	arrayGetList[3] = &DBUFF4;
*/

//==================================================================================
//	INCREMENTAL BUILD OPTIONS - NOTE: selected via {ProjectName-Settings.h
//==================================================================================
// ---------------------------------- USER -----------------------------------------

//----------------------------------------------------------------------
#if (INCR_BUILD == 1) 	// Open Loop Two Phase Interleaved PFC PWM Driver
//----------------------------------------------------------------------
	

	
		// Configure ADC to be triggered from EPWM1 Period event 
   	//Map channel to ADC Pin
   	ChSel[0]=14;		//Map channel 0 to pin ADC-B6
   	// for additional ADC conversions modify below
   	/*ChSel[1]=n;		//An
   	ChSel[2]=n;			//An
   	ChSel[3]=n;			//An
   	ChSel[4]=n;			//An
   	ChSel[5]=n;			//An
   	ChSel[6]=n;			//An
   	ChSel[7]=n;			//An
   	ChSel[8]=n;			//An
   	ChSel[9]=n;			//An
   	ChSel[10]=n;		//An
   	ChSel[11]=n;		//An
   	ChSel[12]=n;		//An
   	ChSel[13]=n;		//An
   	ChSel[14]=n;		//An
   	ChSel[15]=n;		//An
   	*/
   	
   	// Select Trigger Event for ADC conversion 
   	TrigSel[0]= ADCTRIG_EPWM1_SOCA;
   	// associate the appropriate peripheral trigger to the ADC channel
   	/*TrigSel[1]= ADCTRIG_EPWMn_SOCA;
   	TrigSel[2]= ADCTRIG_EPWMn_SOCA;
   	TrigSel[3]= ADCTRIG_EPWMn_SOCA;
   	TrigSel[4]= ADCTRIG_EPWMn_SOCA;
   	TrigSel[5]= ADCTRIG_EPWMn_SOCA;
   	TrigSel[6]= ADCTRIG_EPWMn_SOCA;
   	TrigSel[7]= ADCTRIG_EPWMn_SOCA;
   	TrigSel[8]= ADCTRIG_EPWMn_SOCA;
   	TrigSel[9]= ADCTRIG_EPWMn_SOCA;
   	TrigSel[10]= ADCTRIG_EPWMn_SOCA;
   	TrigSel[11]= ADCTRIG_EPWMn_SOCA;
   	TrigSel[12]= ADCTRIG_EPWMn_SOCA;
   	TrigSel[13]= ADCTRIG_EPWMn_SOCA;
   	TrigSel[14]= ADCTRIG_EPWMn_SOCA;
   	TrigSel[15]= ADCTRIG_EPWMn_SOCA;*/
   	

    // Configure PWM1  for 200Khz (Period Count= 60Mhz/200Khz = 300)
    PWM_ComplPairDB_CNF(1,600, 1, 0);
    PWM_ComplPairDB_UpdateDB(1,10,10);



   	// Configure the ADC with auto interrupt clear mode
   	// ADC interrupt after EOC of channel 0
   	ADC_SOC_CNF(ChSel,TrigSel,ACQPS,0,2); 
   	
   	// Configure the EPWM1 to issue the SOC 
	EPwm1Regs.ETSEL.bit.SOCAEN 	= 1;
	EPwm1Regs.ETSEL.bit.SOCASEL = ET_CTR_PRD;	// Use PRD event as trigger for ADC SOC 
    EPwm1Regs.ETPS.bit.SOCAPRD 	= ET_1ST;        // Generate pulse on every event 
	
	// Digital Power CLA(DP) library initialisation 
	DPL_Init();
	
	// Lib Module connection to "nets" 
	//----------------------------------------
	// Connect the PWM Driver input to an input variable, Open Loop System

	PWMDRV_ComplPairDB_Duty1   = &Duty1;
	Duty1 =_IQ24(0.5);
	PWM_ComplPairDB_UpdateDB(1,10,10);

	// Initialize the net variables
	

#endif // (INCR_BUILD == 1)

//====================================================================================
// INTERRUPTS & ISR INITIALIZATION (best to run this section after other initialization)
//====================================================================================

// Set up C28x Interrupt

//Also Set the appropriate # define's in the {ProjectName}-Settings.h 
//to enable interrupt management in the ISR
	EALLOW;
    PieVectTable.EPWM1_INT = &DPL_ISR;      	// Map Interrupt
   	PieCtrlRegs.PIEIER3.bit.INTx1 = 1;      	// PIE level enable, Grp3 / Int1
   	EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_PRD;  	// INT on PRD event
   	EPwm1Regs.ETSEL.bit.INTEN = 1;              // Enable INT
    EPwm1Regs.ETPS.bit.INTPRD = ET_1ST;         // Generate INT on every event

    IER |= M_INT3;                          	// Enable CPU INT3 connected to EPWM1-6 INTs:
    EINT;                                   	// Enable Global interrupt INTM
    ERTM;                                   	// Enable Global realtime interrupt DBGM
	EDIS;      

//=================================================================================
//	BACKGROUND (BG) LOOP
//=================================================================================

//--------------------------------- FRAMEWORK -------------------------------------
	for(;;)  //infinite loop
	{
		// State machine entry & exit point
		//===========================================================
		(*Alpha_State_Ptr)();	// jump to an Alpha state (A0,B0,...)
		//===========================================================



	}
} //END MAIN CODE



//=================================================================================
//	STATE-MACHINE SEQUENCING AND SYNCRONIZATION
//=================================================================================

//--------------------------------- FRAMEWORK -------------------------------------
void A0(void)
{
	// loop rate synchronizer for A-tasks
	if(CpuTimer0Regs.TCR.bit.TIF == 1)
	{
		CpuTimer0Regs.TCR.bit.TIF = 1;	// clear flag

		//-----------------------------------------------------------
		(*A_Task_Ptr)();		// jump to an A Task (A1,A2,A3,...)
		//-----------------------------------------------------------

		VTimer0[0]++;			// virtual timer 0, instance 0 (spare)
	}

	Alpha_State_Ptr = &B0;		// Comment out to allow only A tasks
}

void B0(void)
{
	// loop rate synchronizer for B-tasks
	if(CpuTimer1Regs.TCR.bit.TIF == 1)
	{
		CpuTimer1Regs.TCR.bit.TIF = 1;				// clear flag

		//-----------------------------------------------------------
		(*B_Task_Ptr)();		// jump to a B Task (B1,B2,B3,...)
		//-----------------------------------------------------------
		VTimer1[0]++;			// virtual timer 1, instance 0 (spare)
	}

	Alpha_State_Ptr = &C0;		// Allow C state tasks
}

void C0(void)
{
	// loop rate synchronizer for C-tasks
	if(CpuTimer2Regs.TCR.bit.TIF == 1)
	{
		CpuTimer2Regs.TCR.bit.TIF = 1;				// clear flag

		//-----------------------------------------------------------
		(*C_Task_Ptr)();		// jump to a C Task (C1,C2,C3,...)
		//-----------------------------------------------------------
		VTimer2[0]++;			//virtual timer 2, instance 0 (spare)
	}

	Alpha_State_Ptr = &A0;	// Back to State A0
}


//=================================================================================
//	A - TASKS
//=================================================================================
//--------------------------------------------------------
void A1(void) 
//--------------------------------------------------------
{
	
	//-------------------
	//the next time CpuTimer0 'counter' reaches Period value go to A2
	A_Task_Ptr = &A2;
	//-------------------
}

//-----------------------------------------------------------------
void A2(void) 
//-----------------------------------------------------------------
{	 
	//-------------------
	//the next time CpuTimer0 'counter' reaches Period value go to A1
	A_Task_Ptr = &A3;
	//-------------------
}

//-----------------------------------------
void A3(void)	
//-----------------------------------------
{
	
	//-----------------
	//the next time CpuTimer0 'counter' reaches Period value go to A1
	A_Task_Ptr = &A4;
	//-----------------
}


//----------------------------------------------------------
void A4(void) 
//---------------------------------------------------------
{
	//-----------------
	//the next time CpuTimer0 'counter' reaches Period value go to A1
	A_Task_Ptr = &A1;
	//-----------------
}


//=================================================================================
//	B - TASKS
//=================================================================================

//----------------------------------- USER ----------------------------------------

//----------------------------------------
void B1(void)
//----------------------------------------
{		
	//-----------------
	//the next time CpuTimer1 'counter' reaches Period value go to B2
	B_Task_Ptr = &B2;	
	//-----------------
}

//----------------------------------------
void B2(void) // Blink LED on the control CArd
//----------------------------------------
{
	if(LedBlinkCnt==0)
		{
			GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1;	//turn on/off LD3 on the controlCARD
			LedBlinkCnt=5;
		}
	else
			LedBlinkCnt--;
			
	//-----------------
	//the next time CpuTimer1 'counter' reaches Period value go to B3
	B_Task_Ptr = &B3;
	//-----------------
}

//----------------------------------------
void B3(void)  
//----------------------------------------
{
	//-----------------
	//the next time CpuTimer1 'counter' reaches Period value go to B4
	B_Task_Ptr = &B4;	
	//-----------------
}

//----------------------------------------
void B4(void) //  SPARE
//----------------------------------------
{
	//-----------------
	//the next time CpuTimer1 'counter' reaches Period value go to B1
	B_Task_Ptr = &B1;	
	//-----------------
}


//=================================================================================
//	C - TASKS
//=================================================================================

//--------------------------------- USER ------------------------------------------

//------------------------------------------------------
void C1(void) 	 
//------------------------------------------------------
{

	//-----------------
	//the next time CpuTimer2 'counter' reaches Period value go to C2
	C_Task_Ptr = &C2;	
	//-----------------

}

//----------------------------------------
void C2(void) 
//----------------------------------------
{

	//-----------------
	//the next time CpuTimer2 'counter' reaches Period value go to C3
	C_Task_Ptr = &C3;	
	//-----------------
}


//-----------------------------------------
void C3(void) 
//-----------------------------------------
{

	//-----------------
	//the next time CpuTimer2 'counter' reaches Period value go to C4
	C_Task_Ptr = &C4;	
	//-----------------
}


//-----------------------------------------
void C4(void) //  SPARE
//-----------------------------------------
{

	//-----------------
	//the next time CpuTimer2 'counter' reaches Period value go to C1
	C_Task_Ptr = &C1;	
	//-----------------
}



The c file for PWM is

//----------------------------------------------------------------------------------
//	FILE:			PWM_ComplPairDB_Cnf.c
//
//	Description:	PWM configuration function for complimentary waveform on A & B
//					with dead band
//
//	Version: 		2.0
//
//  Target:  		TMS320F2802x, 
//					TMS320F2803x, 
//
// The function call is:
//
// 		PWM_ComplPairDB_CNF(int16 n, int16 period, int16 mode, int16 phase)
//
// Function arguments defined as:
//-------------------------------
// n = 		Target ePWM module, 1,2,...16.  e.g. if n=2, then target is ePWM2
// period = PWM period in Sysclks
// mode =	Master/Slave mode, e.g. mode=1 for master, mode=0 for slave
// phase =	phase offset from upstream master in Sysclks,
//			applicable only if mode=0, i.e. slave
//--------------------------------------------------------------------------------
#include "PeripheralHeaderIncludes.h"
#include "DSP2802x_EPWM_defines.h"

extern volatile struct EPWM_REGS *ePWM[];

void PWM_ComplPairDB_CNF(int16 n, int16 period, int16 mode, int16 phase)
{
	// Time Base SubModule Registers	
	(*ePWM[n]).TBCTL.bit.PRDLD = TB_SHADOW;			// set load on CTR=0
	(*ePWM[n]).TBPRD = period-1;					// PWM frequency = 1 / period
	(*ePWM[n]).TBPHS.half.TBPHS = 0;
	(*ePWM[n]).TBCTR = 0;
	
	(*ePWM[n]).TBCTL.bit.CTRMODE = TB_COUNT_UP;
	(*ePWM[n]).TBCTL.bit.HSPCLKDIV = TB_DIV1;
	(*ePWM[n]).TBCTL.bit.CLKDIV = TB_DIV1;

	if (mode == 1) // config as a Master
	{
		(*ePWM[n]).TBCTL.bit.PHSEN = TB_DISABLE;
		(*ePWM[n]).TBCTL.bit.SYNCOSEL = TB_CTR_ZERO; // sync "down-stream" 
	}
	if (mode == 0) // config as a Slave (Note: Phase+2 value used to compensate for logic delay)
	{
		(*ePWM[n]).TBCTL.bit.PHSEN = TB_ENABLE;
		(*ePWM[n]).TBCTL.bit.SYNCOSEL = TB_SYNC_IN;

		if ((0 <= phase)&&(phase <= 2))	(*ePWM[n]).TBPHS.half.TBPHS = (2-phase);
		if (phase > 2)			(*ePWM[n]).TBPHS.half.TBPHS = (period-phase+2);
	}

	// Counter Compare Submodule Registers
	(*ePWM[n]).CMPA.half.CMPA = 0;				// set duty 0% initially
	//(*ePWM[n]).CMPB = 0;						// set duty 0% initially
	(*ePWM[n]).CMPCTL.bit.SHDWAMODE = CC_SHADOW;
	(*ePWM[n]).CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
    (*ePWM[n]).CMPCTL.bit.SHDWBMODE = CC_SHADOW;// edited on 13-06-2022 (this line was not present in original)
    (*ePWM[n]).CMPCTL.bit.LOADBMODE = CC_CTR_ZERO;// edited on 13-06-2022 (this line was not present in original)
	
	// Action Qualifier SubModule Registers
	(*ePWM[n]).AQCTLA.bit.ZRO = AQ_SET;
	(*ePWM[n]).AQCTLA.bit.CAU = AQ_CLEAR;


	(*ePWM[n]).AQCTLB.bit.ZRO = AQ_NO_ACTION;
	(*ePWM[n]).AQCTLB.bit.CAU = AQ_NO_ACTION;
	(*ePWM[n]).AQCTLB.bit.PRD = AQ_NO_ACTION;
//
     // Active high complementary PWMs - Set up the deadband
     (*ePWM[n]).DBCTL.bit.IN_MODE = DBA_ALL;
     (*ePWM[n]).DBCTL.bit.OUT_MODE = DB_FULL_ENABLE;
     (*ePWM[n]).DBCTL.bit.POLSEL = DB_ACTV_HIC;
     (*ePWM[n]).DBRED = 20;
   	 (*ePWM[n]).DBFED = 20;
   	 
}

void PWM_ComplPairDB_UpdateDB(int16 n, int16 dbRED, int16 dbFED)
{
	(*ePWM[n]).DBRED=dbRED;
	(*ePWM[n]).DBFED=dbFED;
}

what could be the issue.