2016-10-04 06:01 AM
Hello. After the initialization CAN interface and call HAL_CAN_Receive_IT function (& hcan, CAN_FIFO0) there is no interruption USB_LP_CAN_RX0_IRQ Handler (); when receiving the CAN package. And accordingly misses the HAL_CAN_RxCpltCallback function (CAN_HandleTypeDef * CanHandle).
Although the function HAL_CAN_Receive (& hcan, CAN_FIFO0, 100); It takes the parcel. Transfer works fine. What can be wrong?void MX_CAN_Init(void)
{
hcan.Instance = CAN;
hcan.Init.Prescaler = 24;
hcan.Init.Mode = CAN_MODE_NORMAL; //CAN_MODE_LOOPBACK CAN_MODE_NORMAL
hcan.Init.SJW = CAN_SJW_1TQ;
hcan.Init.BS1 = CAN_BS1_3TQ;
hcan.Init.BS2 = CAN_BS2_4TQ;
hcan.Init.TTCM = DISABLE;
hcan.Init.ABOM = DISABLE;
hcan.Init.AWUM = DISABLE;
hcan.Init.NART = DISABLE; //ENABLE //DISABLE
hcan.Init.RFLM = DISABLE;
hcan.Init.TXFP = DISABLE;
if (HAL_CAN_Init(&hcan) != HAL_OK)
{
Error_Handler();
}
// на�?траиваем фильтр — приём в�?ех по�?ылок
CAN_FilterConfTypeDef canFilterConfig;
canFilterConfig.FilterNumber = 0;
canFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
canFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
canFilterConfig.FilterIdHigh = 0x0000;
canFilterConfig.FilterIdLow = 0x0000;
canFilterConfig.FilterMaskIdHigh = 0x0000 << 5;
canFilterConfig.FilterMaskIdLow = 0x0000;
canFilterConfig.FilterFIFOAssignment = CAN_FIFO0;
canFilterConfig.FilterActivation = ENABLE;
canFilterConfig.BankNumber = 0;
HAL_CAN_ConfigFilter(&hcan, &canFilterConfig);
if (HAL_CAN_Receive_IT(&hcan, CAN_FIFO0) != HAL_OK)
{
/* Reception Error */
Error_Handler();
}
}
#stm32f302r6 #hal_can_receive_it
2016-10-04 07:53 AM
Hibarinov.denis
, It is related to a recent reported bug in Receive function about FiFONumber. It is under fix phase. Meanwhile , add the following line into can_Receive_IT() function before FMI line :hcan->pRxMsg->FIFONumber = FIFONumber;
-Hannibal-
2016-10-05 12:01 AM
Hi, Hannibal.
I've made everything,accordingly to your advice, but it doesn't work. CAN_Receive_IT() is invoked from HAL_CAN_IRQHandler(), and HAL_CAN_IRQ_Handler() is invoked from USB_LP_CAN_RX0_IRQHandler().The problem is that USB_LP_CAN_RX0_IRQHandler() doesn't work, so HAL_CAN_IRQHandler() and CAN_Receive_IT() are not invoked.But HAL_CAN_Receive(&hcan, CAN_FIFO0, 100) is receiving packets throught CAN.Have no idea, what is going on there.2016-10-07 12:34 AM
2017-12-26 03:13 PM
I'm having the same issue trying to port CAN code from the eval CAN Networking example. So how do you 'initialize the first USB' before doing the CAN_Config()?