欢迎来到天天文库
浏览记录
ID:57319956
大小:35.50 KB
页数:9页
时间:2020-08-11
《基于DSP28035的SPWM生成程序.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include"DSP28x_Project.h"#include"IQmathLib.h"//#include"math.h"#definePWM1_INT_ENABLE1#definePWM2_INT_ENABLE1#definePWM3_INT_ENABLE1#definePWM4_INT_ENABLE1voidInitEPwm1Example(void);voidInitEPwm2Example(void);voidInitEPwm3Example(void);interruptvoidepwm1_timer_isr(void);
2、//interruptvoidepwm2_timer_isr(void);//interruptvoidepwm3_timer_isr(void);Uint32EPwm1TimerIntCount;Uint32EPwm2TimerIntCount;Uint32EPwm3TimerIntCount;Uint32EPwm4TimerIntCount;Uint32TonC1,TonC2;Uint16k;float32Tc,N;#definePI3.float32M=0.8;float32fz=20000;float32fr=50;voidmain
3、(void){InitSysCtrl();InitEPwm1Gpio();//InitEPwm2Gpio();//InitEPwm3Gpio();DINT;InitPieCtrl();IER=0x0000;IFR=0x0000;InitPieVectTable();EALLOW;//ThisisneededtowritetoEALLOWprotectedregistersPieVectTable.EPWM1_INT=&epwm1_timer_isr;//PieVectTable.EPWM2_INT=&epwm2_timer_isr;//Pi
4、eVectTable.EPWM3_INT=&epwm3_timer_isr;EDIS;EALLOW;SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC=0;//StopalltheTBclocksEDIS;InitEPwm1Example();//InitEPwm2Example();//InitEPwm3Example();EALLOW;SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC=1;EDIS;EPwm1TimerIntCount=0;EPwm2TimerIntCount=0;EPwm3TimerI
5、ntCount=0;IER
6、=M_INT3;PieCtrlRegs.PIEIER3.bit.INTx1=PWM1_INT_ENABLE;//PieCtrlRegs.PIEIER3.bit.INTx2=PWM2_INT_ENABLE;//PieCtrlRegs.PIEIER3.bit.INTx3=PWM3_INT_ENABLE;EINT;//EnableGlobalinterruptINTMERTM;for(;;){asm("NOP");}}voidInitEPwm1Example(){EPwm1Regs.TBCTL.bit.SYNCOSEL
7、=TB_CTR_ZERO;//zhuyiEPwm1Regs.TBPRD=1500;//载波周期=2*1500TBCLKEPwm1Regs.TBPHS.half.TBPHS=0x0000;//Phaseis0EPwm1Regs.TBCTL.bit.PRDLD=TB_SHADOW;EPwm1Regs.TBCTR=0x0000;EPwm1Regs.TBCTL.bit.CTRMODE=TB_COUNT_UPDOWN;//CountupdownEPwm1Regs.TBCTL.bit.PHSEN=TB_DISABLE;//Disablephaseloa
8、dingEPwm1Regs.TBCTL.bit.HSPCLKDIV=TB_DIV1;//ClockratiotoSYSCLKOUTEPwm1Regs.TBCTL.bit.CLKDIV=TB_DIV1;EPwm1Regs.CMPCTL.bit.SHDWAMODE=CC_SHADOW;//LoadregisterseveryZERO_PRDEPwm1Regs.CMPCTL.bit.SHDWBMODE=CC_SHADOW;EPwm1Regs.CMPCTL.bit.LOADAMODE=CC_CTR_ZERO_PRD;EPwm1Regs.CMPCTL
9、.bit.LOADBMODE=CC_CTR_ZERO_PRD;EPwm1Regs.CMPA.half.CMPA=1000;EPwm1Regs.AQCTLA.bit.CAU=AQ_
此文档下载收益归作者所有