Part Number:TMS320F28335
如题
interrupt void cpu_timer1_isr(void) {EPwm1Regs.CMPA.half.CMPA=table[a];EPwm2Regs.CMPA.half.CMPA=table[a]; if(++a>=400)a=0;// CpuTimer1.InterruptCount++;// EDIS;//直接确认,无需PIE }
这是中断的,
这是epwm的
void epwm1_gpio() {EALLOW;GpioCtrlRegs.GPAPUD.bit.GPIO0=1;GpioCtrlRegs.GPAPUD.bit.GPIO1=1;GpioCtrlRegs.GPAMUX1.bit.GPIO0=1;//复用IO模式GpioCtrlRegs.GPAMUX1.bit.GPIO1=1;EDIS; } void epwm2_gpio() {EALLOW;GpioCtrlRegs.GPAPUD.bit.GPIO2=1;GpioCtrlRegs.GPAPUD.bit.GPIO3=1;GpioCtrlRegs.GPAMUX1.bit.GPIO2=1;//复用IO模式GpioCtrlRegs.GPAMUX1.bit.GPIO3=1;EDIS; } void epwm1_init() {EPwm1Regs.TBPRD=750;//f=TBPRDx1/时钟频率EPwm1Regs.TBPHS.half.TBPHS=0;EPwm1Regs.TBCTR=0x000;EPwm1Regs.CMPA.half.CMPA=375;EPwm1Regs.CMPB=375;EPwm1Regs.TBCTL.bit.CLKDIV=0;EPwm1Regs.TBCTL.bit.HSPCLKDIV=101;EPwm1Regs.TBCTL.bit.PHSEN=0;EPwm1Regs.TBCTL.bit.CTRMODE=TB_COUNT_UP;EPwm1Regs.TBCTL.bit.PRDLD=0;// EPwm1Regs.TBCTL.bit.SYNCOSEL=1;EPwm1Regs.CMPCTL.bit.SHDWAMODE= 0;EPwm1Regs.CMPCTL.bit.SHDWBMODE= 0;EPwm1Regs.CMPCTL.bit.LOADAMODE= 0;EPwm1Regs.CMPCTL.bit.LOADBMODE= 0;//EPwm1Regs.AQCTLA.bit.CAU=1;//EPwm1Regs.AQCTLA.bit.CAD=2;//EPwm1Regs.AQCTLB.bit.CAU=1;//EPwm1Regs.AQCTLB.bit.CAD=2;EPwm1Regs.AQCTLA.bit.CAU=2;EPwm1Regs.AQCTLA.bit.ZRO=1;EPwm1Regs.AQCTLB.bit.CAU=2;EPwm1Regs.AQCTLB.bit.ZRO=1;// EPwm1Regs.ETCLR.bit.INT=1;// EPwm1Regs.DBCTL.bit.IN_MODE=2;EPwm1Regs.DBCTL.bit.OUT_MODE=3;EPwm1Regs.DBCTL.bit.POLSEL=2;EPwm1Regs.DBRED = 5;EPwm1Regs.DBFED = 5; } void epwm2_init() {EPwm2Regs.TBPRD =750;EPwm2Regs.TBPHS.half.TBPHS=0x00;EPwm2Regs.TBCTR=0x00;EPwm2Regs.CMPA.half.CMPA=375;EPwm2Regs.CMPB=375;EPwm2Regs.TBCTL.bit.CLKDIV=0;EPwm2Regs.TBCTL.bit.HSPCLKDIV=101;EPwm2Regs.TBCTL.bit.PHSEN=0;EPwm2Regs.TBCTL.bit.CTRMODE=TB_COUNT_UP;EPwm2Regs.TBCTL.bit.PRDLD=0;EPwm2Regs.CMPCTL.bit.LOADAMODE=0;EPwm2Regs.CMPCTL.bit.LOADBMODE=0;EPwm2Regs.CMPCTL.bit.SHDWAMODE=0;EPwm2Regs.CMPCTL.bit.SHDWBMODE=0;EPwm2Regs.AQCTLA.bit.CAU=1;EPwm2Regs.AQCTLA.bit.ZRO=2;EPwm2Regs.AQCTLB.bit.CAU=1;EPwm2Regs.AQCTLB.bit.ZRO=2;EPwm2Regs.DBCTL.bit.OUT_MODE=3;EPwm2Regs.DBCTL.bit.POLSEL=2;EPwm2Regs.DBFED=5;EPwm2Regs.DBRED=5; }
Green Deng:
额,抱歉题目没看懂啊。
你是说你的PWM只会出现一个周期,然后要过很久才又出现一个周期?
,
haotian zhao:
没事了,是因为中断的原因
,
Green Deng:
好的,感谢反馈