完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h" // DSP2833x Examples Include File // Prototype statements for functions found within this file. interrupt void ecap1_isr(void); //interrupt void ecap5_isr(void); void InitECapture1(void); // Global variables used in this example Uint32 ECap1IntCount; Uint32 t1,t2,t3,t4,T1,T2; void main(void) { InitSysCtrl(); //ECAP 引脚初始化 InitECap1Gpio(); // InitECap5Gpio(); DINT; InitPieCtrl(); // Disable CPU interrupts and clear all CPU interrupt flags: IER = 0x0000; IFR = 0x0000; InitPieVectTable(); EALLOW; // This is needed to write to EALLOW protected registers //中断响应函数 PieVectTable.ECAP1_INT = &ecap1_isr; // PieVectTable.ECAP5_INT = &ecap5_isr; EDIS; // This is needed to disable write to EALLOW protected registers //ECAP 配置 InitECapture1(); ECap1IntCount = 0; // Enable CPU INT4 which is connected to ECAP1-4 INT: IER |= M_INT4; // Enable eCAP INTn in the PIE: Group 4 interrupt 1-6 PieCtrlRegs.PIEIER4.bit.INTx1 = 1; // Enable global Interrupts and higher priority real-time debug events: EINT; // Enable Global interrupt INTM ERTM; // Enable Global realtime interrupt DBGM // Step 6. IDLE loop. Just sit and loop forever (optional): SysCtrlRegs.PCLKCR1.bit.ECAP1ENCLK=1; for(;;) { asm("NOP"); } } void InitECapture1() { ECap1Regs.ECEINT.all = 0x0000; // Disable all capture interrupts ECap1Regs.ECCLR.all = 0xFFFF; // Clear all CAP interrupt flags ECap1Regs.ECCTL1.bit.CAPLDEN = 0; // Disable CAP1-CAP4 register loads ECap1Regs.ECCTL2.bit.TSCTRSTOP = 0; // Make sure the counter is stopped // Configure peripheral registers ECap1Regs.ECCTL2.bit.CAP_APWM = 0; // ECAP模式,另一种模式是APWM ECap1Regs.ECCTL2.bit.CONT_ONESHT = 0; // One shot ECap1Regs.ECCTL2.bit.STOP_WRAP = 3; // Stop at 1 events ECap1Regs.ECCTL1.bit.CAP1POL = 0; // 默认配置上升沿触发 ECap1Regs.ECCTL1.bit.CAP2POL = 1; // Falling edge ECap1Regs.ECCTL1.bit.CAP3POL = 0; // Rising edge ECap1Regs.ECCTL1.bit.CAP4POL = 1; // Falling edge ECap1Regs.ECCTL1.bit.CTRRST1 = 0; // Difference operation ECap1Regs.ECCTL1.bit.CTRRST2 = 0; // Difference operation ECap1Regs.ECCTL1.bit.CTRRST3 = 0; // Difference operation ECap1Regs.ECCTL1.bit.CTRRST4 = 1; // Difference operation ECap1Regs.ECCTL2.bit.SYNCI_EN = 0; // Disable sync ECap1Regs.ECCTL2.bit.SYNCO_SEL = 2; // Disable sync out ECap1Regs.ECCTL1.bit.PRESCALE = 0; //1分频(不分频) ECap1Regs.ECCTL1.bit.CAPLDEN = 1; // Enable CAP1-CAP4 register loads ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter // ECap1Regs.ECCTL2.bit.REARM = 1; // arm one-shot ECap1Regs.ECEINT.bit.CEVT4 = 1; // CEVENT = interrupt } interrupt void ecap1_isr(void) { ECap1IntCount++; t1 = ECap1Regs.CAP1; t2 = ECap1Regs.CAP2; t3 = ECap1Regs.CAP3; t4 = ECap1Regs.CAP4; T1=t3-t1; T2=t4-t2; ECap1Regs.ECCLR.bit.CEVT4 = 1; // CEVENT events = interrupt ECap1Regs.ECCLR.bit.INT = 1; // ECap1Regs.ECCTL2.bit.REARM = 1; // Acknowledge this interrupt to receive more interrupts from group 4 PieCtrlRegs.PIEACK.all = PIEACK_GROUP4; } 用f28335测量外接脉冲的频率,请问这程序哪里有问题呀? 设置断点查看变量值 为什么ECap1Regs.CAP1 ECap1Regs.CAP2 ECap1Regs.CAP3 ECap1Regs.CAP4的值都一样啊 还有ECap1Regs.CAP3-ECap1Regs.CAP1的值就是一个周期 有错么? 谢谢指导 |
|
相关推荐 |
|
基于 DSP5509 进行数字图像处理中 Sobel 算子边缘检测的硬件连接电路图
2426 浏览 0 评论
695 浏览 0 评论
普中科技F28335开发板中,如何使用aic23播放由代码生成的正弦波
2865 浏览 0 评论
3629 浏览 1 评论
1205 浏览 1 评论
浏览过的版块 |
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 00:19 , Processed in 0.563029 second(s), Total 42, Slave 33 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号