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.
When using TMS320F28335, you want to use the monitoring window to view the value of EPwm6Regs.CMPA.half.CMPA, and then use the "Graph" function of CCS software to view the waveform after EPwm6Regs.CMPA.half.CMPA.
The ideal waveform of EPwm6Regs.CMPA.half.CMPA should be a sine wave on the 0 scale line. I observed this waveform with an oscilloscope.
In fact, when I use "step into", the value of EPwm6Regs.CMPA.half.CMPA increases normally, and the output waveform with "Graph" is also normal. However, when I use "resume" for operation debugging, The change of the value of EPwm6Regs.CMPA.half.CMPA cannot be seen in the monitoring window, and the output waveform is no longer an ideal sine wave.
I wonder why this is the case, and hope to get some help.
I have attached the code I am using below.
main.c
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File #include "DSP2833x_Examples.h" // DSP2833x Examples Include File #include "Math.h" //#include "pwm.h" interrupt void epwm6_timer_isr(void); //函数的声明,因为函数体的定义在最后,这个是自己定义的 void EPWM6_Init(Uint16 tbprd); int N=256; int i,k=0; float m=1,b;//设置调制度 float sina[256]; float sinb[256]; /******************************************************************************* * 函 数 名 : main * 函数功能 : 主函数 * 输 入 : 无 * 输 出 : 无 *******************************************************************************/ void main() { InitSysCtrl(); InitPieCtrl(); IER = 0x0000; IFR = 0x0000; InitPieVectTable(); EALLOW; PieVectTable.EPWM6_INT =&epwm6_timer_isr; EDIS; // LED_Init(); EPWM6_Init(7500); for(k=0;k<N;k++) { sina[k]= sin(2*3.1416*k/N); sinb[k]= sin(2*3.1416*k/N); } IER |= M_INT3; PieCtrlRegs.PIEIER3.bit.INTx6 = 1; //外部中断 使能第三组中断的第6个小中断 EINT; //开CPU级中断响应 ERTM; for(;;){ __asm(" NOP"); } } void EPWM6_Init(Uint16 tbprd) { EALLOW; SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0; // Disable TBCLK within the ePWM SysCtrlRegs.PCLKCR1.bit.EPWM6ENCLK = 1; // ePWM6 EDIS; InitEPwm6Gpio(); // Setup Sync EPwm6Regs.TBCTL.bit.SYNCOSEL = TB_SYNC_DISABLE; // Pass through // Allow each timer to be sync'ed EPwm6Regs.TBCTL.bit.PHSEN = TB_DISABLE; EPwm6Regs.TBPHS.half.TBPHS = 0; EPwm6Regs.TBCTR = 0x0000; // Clear counter EPwm6Regs.TBPRD = tbprd; EPwm6Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up EPwm6Regs.TBCTL.bit.HSPCLKDIV=TB_DIV1; EPwm6Regs.TBCTL.bit.CLKDIV=TB_DIV1; // Setup shadow register load on ZERO EPwm6Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; EPwm6Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW; EPwm6Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; EPwm6Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // Set Compare values EPwm6Regs.CMPA.half.CMPA = 0; // Set compare A value EP
EPwm6Regs.CMPA.half.CMPA value calculation formula:
thanks!!!