Part Number:TMS320F28027F
Tool/software: Code Composer Studio
Hey Everyone ,
I am configuring the PWM of 20kHz for which I am Using TBPRD =1500,the code is written below but the thing is the the duty cycle does not work beyond CMPA=550, i.e the output goes always low as i touch the value more than 450 the picture is also attached for reference from which the yellow is EPWM1 and blue is EPWM2. Can some please help with this problem
#include "DSP28x_Project.h" #define EPWM1_TIMER_TBPRD 1500 void GPIO_SELECT(void); void INIT_ePWM1(void); void INIT_ePWM2(void); int Input(void); int main(void) { #ifdef _FLASH memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize); #endif InitSysCtrl(); GPIO_SELECT(); for(;;) { INIT_ePWM1(); INIT_ePWM2(); } } void GPIO_SELECT(void) { EALLOW; GpioCtrlRegs.GPAPUD.bit.GPIO0 = 0; GpioCtrlRegs.GPAPUD.bit.GPIO1 = 0; GpioCtrlRegs.GPAPUD.bit.GPIO2 = 0; GpioCtrlRegs.GPAPUD.bit.GPIO3 = 0; GpioCtrlRegs.GPAPUD.bit.GPIO4 = 0; GpioCtrlRegs.GPAPUD.bit.GPIO5 = 0; GpioCtrlRegs.GPAPUD.bit.GPIO6 = 0; GpioCtrlRegs.GPAPUD.bit.GPIO7 = 0; GpioCtrlRegs.GPAPUD.bit.GPIO12 = 0; GpioCtrlRegs.GPAMUX1.bit.GPIO0= 1; GpioCtrlRegs.GPAMUX1.bit.GPIO2= 1; GpioCtrlRegs.GPAMUX1.bit.GPIO4= 1; GpioCtrlRegs.GPAMUX1.bit.GPIO5= 0; GpioCtrlRegs.GPAMUX1.bit.GPIO6= 0; GpioCtrlRegs.GPAMUX1.bit.GPIO7= 0; GpioCtrlRegs.GPAMUX1.bit.GPIO1= 0; GpioCtrlRegs.GPAMUX1.bit.GPIO3= 0; GpioCtrlRegs.GPAMUX1.bit.GPIO12= 0; GpioCtrlRegs.GPADIR.bit.GPIO5 = 0; GpioCtrlRegs.GPADIR.bit.GPIO6 = 0; GpioCtrlRegs.GPADIR.bit.GPIO7 = 0; GpioCtrlRegs.GPADIR.bit.GPIO1 = 1; GpioCtrlRegs.GPADIR.bit.GPIO3 = 1; GpioCtrlRegs.GPADIR.bit.GPIO12 = 1; EDIS; } void INIT_ePWM1(void) { EPwm1Regs.TBPRD= EPWM1_TIMER_TBPRD ; EPwm1Regs.TBPHS.half.TBPHS= 0; EPwm1Regs.TBCTR= 0x0000; EPwm1Regs.CMPA.half.CMPA = 550; EPwm1Regs.TBCTL.bit.CTRMODE = 0x2; EPwm1Regs.TBCTL.bit.PHSEN=0x0; EPwm1Regs.TBCTL.bit.SYNCOSEL=0x1; EPwm1Regs.CMPCTL.bit.SHDWAMODE = 0x0; EPwm1Regs.CMPCTL.bit.LOADAMODE = 0x0; EPwm1Regs.AQCTLA.bit.ZRO = 0x1; EPwm1Regs.AQCTLA.bit.PRD = 0x0; EPwm1Regs.AQCTLA.bit.CAU = 0x2; EPwm1Regs.AQCTLA.bit.CAD = 0x1; }; void INIT_ePWM2(void) { EPwm2Regs.TBPRD= EPWM1_TIMER_TBPRD ; EPwm2Regs.TBPHS.half.TBPHS= 0; EPwm2Regs.TBCTR= 0x0000; EPwm2Regs.CMPA.half.CMPA = 450; EPwm2Regs.TBCTL.bit.CTRMODE = 0x2; EPwm2Regs.TBCTL.bit.PHSEN=0x0; EPwm2Regs.TBCTL.bit.SYNCOSEL=0x1; EPwm2Regs.CMPCTL.bit.SHDWAMODE = 0x0; EPwm2Regs.CMPCTL.bit.LOADAMODE = 0x0; EPwm2Regs.AQCTLA.bit.ZRO = 0x1; EPwm2Regs.AQCTLA.bit.PRD = 0x0; EPwm2Regs.AQCTLA.bit.CAU = 0x2; EPwm2Regs.AQCTLA.bit.CAD = 0x1; };