我使用的是片上驱动,初始化函数如下
void CAN_Initial()
{
(*rom)->pCANAPI->init_can(&CanApiClkInitTable[0]);
NVIC_EnableIRQ(CAN_IRQn);
NVIC_SetPriority(CAN_IRQn, 1);
(*rom)->pCANAPI->config_calb((CAN_CALLBACKS *)&callbacks);
msg_obj.mask = 0x00L; /*不屏蔽任何ID*/
msg_obj.dlc = 8;
msg_obj.mode_id = 0x123L;
msg_obj.msgobj = 0x05;
msg_obj_RX.msgobj = 0x0;
msg_obj_RX.mode_id = CAN_MSGOBJ_STD | CAN_MSGOBJ_DAT | 0x00; //
msg_obj_RX.mask = 0;
(*rom)->pCANAPI->config_rxmsgobj(&msg_obj_RX);
}
错误中断回调函数如下
void CAN_error(uint32_t error_info)
{
if(error_info&CAN_ERROR_PASS)
{Indicator_light_Mode_Change(1,1);}
if(error_info&CAN_ERROR_WARN)
{Indicator_light_Mode_Change(1,2);CAN_ERR_Count = 96;}
if(error_info&CAN_ERROR_BOFF)
{Indicator_light_Mode_Change(1,3);CAN_Initial();CAN_ERR_Count = 128;}
if(error_info&CAN_ERROR_ACK)
{Indicator_light_Mode_Change(1,4);}
return ;
}
每种错误只能进入中断一次,之后再出错也没有用,不会进入中断,这是什么原因呢,该怎么解决?
|
|