完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
#include "DSP2833x_Device.h" // DSP2833xHeaderfile Include File #include "DSP2833x_Examples.h" // DSP2833xExamples Include File // Prototypestatements for functions found within this file. interrupt void EPWM1_TZINT_ISR(void); void InitEPwm1Example(); void main(void) { InitSysCtrl(); InitEPwm1Gpio(); EALLOW; GpioCtrlRegs.GPAMUX1.bit.GPIO12=0x1; EDIS; DINT; InitPieCtrl(); // Disable CPUinterrupts and clear all CPU interrupt flags: IER = 0x0000; IFR = 0x0000; InitPieVectTable(); EALLOW; // This isneeded to write to EALLOW protected registers PieVectTable.EPWM1_TZINT = &EPWM1_TZINT_ISR;//EPWM1_TZINT_ISR; EDIS; // This isneeded to disable write to EALLOW protected registers InitEPwm1Example(); // InitEPwm2Example(); IER|=M_INT2; PieCtrlRegs.PIEIER2.bit.INTx1=1; EINT; // EnableGlobal interrupt INTM ERTM; // EnableGlobal realtime interrupt DBGM // Step 6. IDLEloop. Just sit and loop forever (optional): for(;;) { __asm(" NOP"); } } void InitEPwm1Example() { EPwm1Regs.TBPRD = 937.5; // Set timer period EPwm1Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0 EPwm1Regs.TBCTR = 0x0000; // Clear counter EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV4; // Clock ratio to SYSCLKOUT EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV4; EPwm1Regs.TBCTL.bit.SYNCOSEL=0x01; EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; // Load registers every ZERO EPwm1Regs.CMPCTL.bit.SHDWBMODE = CC_SHADOW; EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO; EPwm1Regs.CMPCTL.bit.LOADBMODE = CC_CTR_ZERO; // Set actions EPwm1Regs.AQCTLA.bit.ZRO = 0x2;//AQ_SET; // Set PWM1A on Zero EPwm1Regs.AQCTLA.bit.PRD = 0x1;//AQ_CLEAR; // Active Low PWMs - Setup Deadband EPwm1Regs.DBCTL.bit.OUT_MODE = 0x3;//DB_FULL_ENABLE; EPwm1Regs.DBCTL.bit.POLSEL = 0x2;//DB_ACTV_LO; EPwm1Regs.DBCTL.bit.IN_MODE = 0x0;//DBA_ALL; EPwm1Regs.DBRED = 30;//EPWM1_MIN_DB; EPwm1Regs.DBFED = 30;//EPWM1_MIN_DB; // EPwm1_DB_Direction = DB_UP; EPwm1Regs.TZSEL.bit.OSHT1=1; EPwm1Regs.TZEINT.bit.OST=1; // Interrupt where we will change the Deadband EPwm1Regs.ETSEL.bit.INTSEL = ET_CTR_ZERO; // Select INT on Zero event EPwm1Regs.ETSEL.bit.INTEN = 1; // Enable INT EPwm1Regs.ETPS.bit.INTPRD = ET_3RD; // Generate INT on 3rd event } // Interruptroutines uses in this example: interrupt void EPWM1_TZINT_ISR(void) { EPwm1Regs.TZCTL.bit.TZA=0x2; EPwm1Regs.TZCTL.bit.TZB=0x2; EPwm1Regs.ETCLR.bit.INT=1; PieCtrlRegs.PIEACK.all=PIEACK_GROUP2; EPwm1Regs.AQSFRC.all=0xc0; EPwm1Regs.AQCSFRC.bit.CSFA=0x1; EPwm1Regs.AQCSFRC.bit.CSFB=0x1; asm (" ESTOP0"); for(;;); } |
|
相关推荐
4个回答
|
|
有人么?新人求教啊
|
|
|
|
学习了
|
|
|
|
|
|
|
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
基于 DSP5509 进行数字图像处理中 Sobel 算子边缘检测的硬件连接电路图
3126 浏览 0 评论
777 浏览 0 评论
普中科技F28335开发板中,如何使用aic23播放由代码生成的正弦波
3560 浏览 0 评论
4326 浏览 1 评论
1350 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-19 21:57 , Processed in 0.510883 second(s), Total 55, Slave 44 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号