void SetCap1(void)
{
ECap1Regs.ECCTL1.bit.CAP1POL = 0;
ECap1Regs.ECCTL1.bit.CAP2POL = 0;
ECap1Regs.ECCTL1.bit.CTRRST1 = 0;
ECap1Regs.ECCTL1.bit.CTRRST2 = 0;
ECap1Regs.ECCTL1.bit.CAPLDEN = 1;
ECap1Regs.ECCTL1.bit.PRESCALE = 0;
ECap1Regs.ECCTL2.bit.CAP_APWM = 0;
ECap1Regs.ECCTL2.bit.CONT_ONESHT = 0;
ECap1Regs.ECCTL2.bit.SYNCO_SEL = 2;
ECap1Regs.ECCTL2.bit.SYNCI_EN = 0;
ECap1Regs.ECEINT.all = 0x0000;
ECap1Regs.ECCLR.all = 0xFFFF;
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1;
ECap1Regs.ECEINT.bit.CEVT2 = 1;
}
interrupt void Cap1_isr(void)
{
PieCtrlRegs.PIEACK.all = PIEACK_GROUP4;
ECap1Regs.ECCLR.all = 0xFFFF;
t4 = ECap1Regs.CAP1;
t5 = ECap1Regs.CAP2;
T1 = t5-t4;
F4 = 200 / T1;
}
void InitEcap1Gpio(void)
{
GpioCtrlRegs.GPAPUD.bit.GPIO24 = 0;
GpioCtrlRegs.GPAQSEL2.bit.GPIO24 = 0;
GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 1;
EDIS;
}
void InitCap(void)
{
InitEcap1Gpio();
SetCap1();
}
主函数中加的东西没有赘述。
主要想问 ECap1Regs.ECEINT.bit.CEVT2 = 1;这个配置是不是意味着在捕获第二次上升沿(下降沿)的时候进入中断。
但是我的程序没有进入中断,是不是我的中断程序编写也有问题。望大神不吝赐教。
此帖出自
小平头技术问答
一周热门 更多>