2018-08-16 10:31 PM
Hi guys, my codes go into interrupt function just one time.Could you offer me any solution?
CAN // 1. device
hcan.Init.Prescaler = 4;
hcan.Init.Mode = CAN_MODE_NORMAL;
hcan.Init.SJW = CAN_SJW_4TQ;
hcan.Init.BS1 = CAN_BS1_4TQ;
hcan.Init.BS2 = CAN_BS2_5TQ;
CAN // 2.Device
hcan1.Init.Prescaler = 5;
hcan1.Init.Mode = CAN_MODE_NORMAL;
hcan1.Init.SJW = CAN_SJW_4TQ;
hcan1.Init.BS1 = CAN_BS1_4TQ;
hcan1.Init.BS2 = CAN_BS2_5TQ;
Solved! Go to Solution.
2018-08-16 10:57 PM
OK it is solved. Problem is that "HAL_CAN_Receive_IT(&hcan1, CAN_FIFO0); " function must be below in function.
extern "C" void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef* CanHandle)
{
//HAL_CAN_Receive_IT(&hcan1, CAN_FIFO0);
if(hcan1.pRxMsg->StdId == SLAVE_CAN_ID)
{
if(hcan1.pRxMsg->Data[4] == US.index)
{
US.slaveDataOK[US.index-1] = true;
}
}
HAL_CAN_Receive_IT(&hcan1, CAN_FIFO0);
}
2018-08-16 10:57 PM
OK it is solved. Problem is that "HAL_CAN_Receive_IT(&hcan1, CAN_FIFO0); " function must be below in function.
extern "C" void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef* CanHandle)
{
//HAL_CAN_Receive_IT(&hcan1, CAN_FIFO0);
if(hcan1.pRxMsg->StdId == SLAVE_CAN_ID)
{
if(hcan1.pRxMsg->Data[4] == US.index)
{
US.slaveDataOK[US.index-1] = true;
}
}
HAL_CAN_Receive_IT(&hcan1, CAN_FIFO0);
}