专家
公告
财富商城
电子网
旗下网站
首页
问题库
专栏
标签库
话题
专家
NEW
门户
发布
提问题
发文章
TI
求DSPC2000 F28027eCAP完整项目文件
2019-08-01 16:53
发布
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
站内问答
/
TI MCU
6267
10
1722
在论坛找了一个eCAP程序,改了一下,结果进不了中断,而且GPIO19脚还是高电平,求解决
友情提示:
此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
10条回答
wangjinlili
2019-08-01 22:34
高电平,求解决,代码如下:
void InitECapture()
{
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; //CAP mode
ECap1Regs.ECCTL2.bit.CONT_ONESHT = 0; // continuous mode
ECap1Regs.ECCTL2.bit.STOP_WRAP = 1; // Stop at 2 events
ECap1Regs.ECCTL1.bit.PRESCALE = 0; // Divide by 1
ECap1Regs.ECCTL1.bit.CAP1POL = 0; // Rising edge
ECap1Regs.ECCTL1.bit.CAP2POL = 0; // Rising edge
ECap1Regs.ECCTL1.bit.CTRRST1 = 1; // Difference operation
ECap1Regs.ECCTL1.bit.CTRRST2 = 0; // Difference operation
ECap1Regs.ECCTL2.bit.SYNCI_EN = 0; // Enable sync in
ECap1Regs.ECCTL2.bit.SYNCO_SEL = 3; // Disable sync out signal
ECap1Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap1Regs.ECEINT.bit.CEVT2 = 1; // 2 events = interrupt
}
void main(void)
{
InitSysCtrl();
EALLOW; //允许访问受保护的空间
GpioCtrlRegs.GPADIR.bit.GPIO1=1;
GpioDataRegs.GPADAT.bit.GPIO1=1;
EDIS;
InitECap1Gpio();
InitECapture();
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.ECAP1_INT = &ecap1_isr;
EDIS; // This is needed to disable write to EALLOW protected registers // Enable CPU INT4 which is connected to ECAP1-4 INT:
IER |= M_INT4;
PieCtrlRegs.PIEIER4.bit.INTx1 = 1;
// Enable eCAP INTn in the PIE: Group 3 interrupt 1-6
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
while(1);
}
interrupt void ecap1_isr(void)
{
//ECap1Count = ECap1Regs.CAP1;
ECap2Count = ECap1Regs.CAP2;
GpioDataRegs.GPADAT.bit.GPIO1=0;
//ECap1Regs.ECCLR.all = 0xFFFF;
ECap1Regs.ECCLR.bit.CEVT2 = 1;
ECap1Regs.ECCLR.bit.CEVT1 = 1;
ECap1Regs.ECCLR.bit.INT = 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}
加载中...
查看其它10个回答
一周热门
更多
>
相关问题
CPLD的方波输出
4 个回答
11个版本Quartus II 软件下载,安装包网盘合集,附教程,47G!
20 个回答
请大家帮忙到21IC发展大家谈支持我申请新版面
20 个回答
【通知】21ic中国电子网服务条款 (所有人员必读)
1 个回答
满载而归乙亥年,大展鸿途庚子年---集签赢好礼
20 个回答
相关文章
×
关闭
采纳回答
向帮助了您的知道网友说句感谢的话吧!
非常感谢!
确 认
×
关闭
编辑标签
最多设置5个标签!
TI
保存
关闭
×
关闭
举报内容
检举类型
检举内容
检举用户
检举原因
广告推广
恶意灌水
回答内容与提问无关
抄袭答案
其他
检举说明(必填)
提交
关闭
×
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
×
付费偷看金额在0.1-10元之间
确定
×
关闭
您已邀请
0
人回答
查看邀请
擅长该话题的人
回答过该话题的人
我关注的人
void InitECapture()
{
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; //CAP mode
ECap1Regs.ECCTL2.bit.CONT_ONESHT = 0; // continuous mode
ECap1Regs.ECCTL2.bit.STOP_WRAP = 1; // Stop at 2 events
ECap1Regs.ECCTL1.bit.PRESCALE = 0; // Divide by 1
ECap1Regs.ECCTL1.bit.CAP1POL = 0; // Rising edge
ECap1Regs.ECCTL1.bit.CAP2POL = 0; // Rising edge
ECap1Regs.ECCTL1.bit.CTRRST1 = 1; // Difference operation
ECap1Regs.ECCTL1.bit.CTRRST2 = 0; // Difference operation
ECap1Regs.ECCTL2.bit.SYNCI_EN = 0; // Enable sync in
ECap1Regs.ECCTL2.bit.SYNCO_SEL = 3; // Disable sync out signal
ECap1Regs.ECCTL1.bit.CAPLDEN = 1; // Enable capture units
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1; // Start Counter
ECap1Regs.ECEINT.bit.CEVT2 = 1; // 2 events = interrupt
}
void main(void)
{
InitSysCtrl();
EALLOW; //允许访问受保护的空间
GpioCtrlRegs.GPADIR.bit.GPIO1=1;
GpioDataRegs.GPADAT.bit.GPIO1=1;
EDIS;
InitECap1Gpio();
InitECapture();
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.ECAP1_INT = &ecap1_isr;
EDIS; // This is needed to disable write to EALLOW protected registers // Enable CPU INT4 which is connected to ECAP1-4 INT:
IER |= M_INT4;
PieCtrlRegs.PIEIER4.bit.INTx1 = 1;
// Enable eCAP INTn in the PIE: Group 3 interrupt 1-6
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
while(1);
}
interrupt void ecap1_isr(void)
{
//ECap1Count = ECap1Regs.CAP1;
ECap2Count = ECap1Regs.CAP2;
GpioDataRegs.GPADAT.bit.GPIO1=0;
//ECap1Regs.ECCLR.all = 0xFFFF;
ECap1Regs.ECCLR.bit.CEVT2 = 1;
ECap1Regs.ECCLR.bit.CEVT1 = 1;
ECap1Regs.ECCLR.bit.INT = 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
}
一周热门 更多>