标准的TI例程中,设置用CAP4、CAP5中断处理霍尔信号,有刷电机,里面装的是HALL传感器用于计算转速
主函数定义了
interrupt void CAPINT4_ISR(void);
PieVectTable.CAPINT4 = &CAPINT4_ISR;
PieCtrlRegs.PIEIER5.bit.INTx5 = 1;//CAP4INT Enable
IER |= M_INT5;
初始化EV中CAP,这里调用的是初始化函数以及参与计算的read函数
void
F281X_EV2_CAP_Init(CAPTURE *p)
{
EvbRegs.CAPCONB.all = CAP_INIT_STATE;
EvbRegs.T4CON.all = TIMER_INIT_STATE;
EvbRegs.T4PR = 0x7FFF;
EvbRegs.CAPFIFOB.bit.CAP4FIFO = 0x01;
EvbRegs.EVBIFRC.bit.CAP4INT = 1;
EvbRegs.EVBIMRC.bit.CAP4INT = 1;
EALLOW;
GpioMuxRegs.GPBMUX.all |= 0x0700;
EDIS;
}
Uint16 F281X_EV2_CAP_Read(CAPTURE *p)
{
if((EvbRegs.CAPFIFOB.all & 0x0100) != 0)
{
p->TimeStamp = EvbRegs.CAP4FIFO;
return(0);
}
else
{
return(1);
}
}
测试是否进入中断的函数
#if (DSP_TARGET==F2812)
interrupt void CAPINT4_ISR(void)
{
flag_HALLspeed++;
cap1.read(&cap1);
EvbRegs.CAPFIFOB.bit.CAP4FIFO = 0x01;
EvbRegs.EVBIFRC.bit.CAP4INT = 0x1;
EvbRegs.EVBIMRC.bit.CAP4INT = 0x1;
PieCtrlRegs.PIEACK.all |= PIEACK_GROUP5;
EINT;
}
#endif
测试的结果是一直没有进入中断,
if((EvbRegs.CAPFIFOB.all & 0x0100) != 0)
{
p->TimeStamp = EvbRegs.CAP4FIFO;
return(0);
}
上面这段程序一直没有执行
|