本帖最后由 雪雨风霜 于 2015-6-18 18:40 编辑
大家好,我用的是STM32F207芯片,在直流充电桩上面应用。芯片的两个CAN口都被利用到了。
目前出现的问题是:其中一路和电动汽车BMS通信的CAN口的中断在启动前期可以进入中断,到某一时候(大约可以收到90多帧数据)(未知),CAN中断突然进不去了,其他中断正常。而且该CAN口重新初始化之后又可以进入,但是会重复之前的现象。
CAN设置如下:
CAN_FilterConfTypeDef sFilterConfig;
static CanTxMsgTypeDef TxMessage1;
static CanRxMsgTypeDef RxMessage1;
CanHandleToBMS.Instance = CAN1;
CanHandleToBMS.pTxMsg = &TxMessage1;
CanHandleToBMS.pRxMsg = &RxMessage1;
//CAN 初始化 30MHz 250kbps
CanHandleToBMS.Init.TTCM = DISABLE;
CanHandleToBMS.Init.ABOM = DISABLE;
CanHandleToBMS.Init.AWUM = DISABLE;
CanHandleToBMS.Init.NART = DISABLE;
CanHandleToBMS.Init.RFLM = DISABLE;
CanHandleToBMS.Init.TXFP = DISABLE;
CanHandleToBMS.Init.Mode = CAN_MODE_NORMAL;
CanHandleToBMS.Init.SJW = CAN_SJW_1TQ;
CanHandleToBMS.Init.BS1 = CAN_BS1_6TQ;
CanHandleToBMS.Init.BS2 = CAN_BS2_8TQ;
CanHandleToBMS.Init.Prescaler = 8;
HAL_CAN_Init(&CanHandleToBMS);
//CAN过滤器
/*##-2- Configure the CAN Filter ###########################################*/
sFilterConfig.FilterNumber = 0;
sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
sFilterConfig.FilterIdHigh = 0x0000;
sFilterConfig.FilterIdLow = 0x0000;
sFilterConfig.FilterMaskIdHigh = 0x0000;
sFilterConfig.FilterMaskIdLow = 0x0000;
sFilterConfig.FilterFIFOAssignment = CAN_FIFO0;
sFilterConfig.FilterActivation = ENABLE;
sFilterConfig.BankNumber = 14;
HAL_CAN_ConfigFilter(&CanHandleToBMS, &sFilterConfig);
CAN回调函数如下:
if(CanHandle->pRxMsg->IDE == CAN_ID_EXT) //判断扩展帧
{
if(CanHandle->Instance == CAN1) //判断BMS的CAN进入中断
{
CANBMS.IDE = CanHandle->pRxMsg->ExtId;
CANBMS.DLC = CanHandle->pRxMsg->DLC;
for(i=0;i<8;i++)
{
CANBMS.Data = CanHandle->pRxMsg->Data;
}
CANqueue_push(CANBMS);
HAL_CAN_Receive_IT(CanHandle, CAN_FIFO0);
}
}
不知道大家有没有出现类似的问题,谢谢 |