如题,调试Cap模块的过程中CAP寄存器始终没有数值,以下是我的代码:
void main(void)
{
InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
DELAY_US(1000L);
EALLOW;
SysCtrlRegs.PCLKCR1.bit.ECAP1ENCLK = 1;
SysCtrlRegs.PCLKCR1.bit.ECAP2ENCLK = 1;
EDIS;
InitECapGpio();
Init_ecap();
while(1)
{
}
}
void Init_ecap()
{
ECap1Regs.ECCTL1.all = 0x0000;
ECap1Regs.ECCTL1.bit.CAPLDEN = 1;
ECap1Regs.ECCTL2.bit.CAP_APWM = 0; //工作在捕获模式
ECap1Regs.ECCTL2.bit.CONT_ONESHT = 0; //工作在连续模式
ECap1Regs.ECCTL2.bit.SYNCO_SEL = 2; //禁止SYNC_OUT输出信号
ECap1Regs.ECCTL2.bit.SYNCI_EN = 0; //禁止同步功能
ECap2Regs.ECCTL1.all = 0x0000;
ECap2Regs.ECCTL1.bit.CAPLDEN = 1;
ECap2Regs.ECCTL2.bit.CAP_APWM = 0; //工作在捕获模式
ECap2Regs.ECCTL2.bit.CONT_ONESHT = 0; //工作在连续模式
ECap2Regs.ECCTL2.bit.SYNCO_SEL = 2; //禁止SYNC_OUT输出信号
ECap2Regs.ECCTL2.bit.SYNCI_EN = 0; //禁止同步功能
/*捕获事件中断使能*/
ECap1Regs.ECEINT.all = 0;
ECap1Regs.ECCLR.all &= 0xFF;
ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1; //启动cap1计时器
ECap1Regs.ECEINT.bit.CEVT1 = 1;
ECap1Regs.ECEINT.bit.CEVT2 = 1;
ECap1Regs.ECEINT.bit.CEVT3 = 1;
ECap1Regs.ECEINT.bit.CEVT4 = 1;
ECap2Regs.ECEINT.all = 0;
ECap2Regs.ECCLR.all &= 0xFF;
ECap2Regs.ECCTL2.bit.TSCTRSTOP = 1; //启动cap2计时器
ECap2Regs.ECEINT.bit.CEVT1 = 1;
ECap2Regs.ECEINT.bit.CEVT2 = 1;
ECap2Regs.ECEINT.bit.CEVT3 = 1;
ECap2Regs.ECEINT.bit.CEVT4 = 1;
} |