2024-03-03 05:25 AM
Hi All,
I have a peculiar observation in one of our legacy codes, wherein I do not observe RX FIFO 1 callback being triggered.
I observe hfdcan1.Init.ExtFiltersNbr is set to 0 and HAL_FDCAN_ConfigFilter() is NOT called. I am unaware if this is purposely done to use all available filters.
It also appears to me that the way the CAN driver is set-up / Initalized, microcontroller is accepting all CAN messages in FIFO 0 even when a line of code is added in initialization to enable the bit 4 (i.e., FDCAN_IE_RF1NE) of CAN IE register.
static void MX_FDCAN1_Init(void)
{
/* USER CODE BEGIN FDCAN1_Init 0 */
/* USER CODE END FDCAN1_Init 0 */
/* USER CODE BEGIN FDCAN1_Init 1 */
/* USER CODE END FDCAN1_Init 1 */
hfdcan1.Instance = FDCAN1;
hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;
hfdcan1.Init.AutoRetransmission = ENABLE;
hfdcan1.Init.TransmitPause = DISABLE;
hfdcan1.Init.ProtocolException = DISABLE;
hfdcan1.Init.NominalPrescaler = v1;
hfdcan1.Init.NominalSyncJumpWidth = 1;
hfdcan1.Init.NominalTimeSeg1 = v2;
hfdcan1.Init.NominalTimeSeg2 = v3;
hfdcan1.Init.DataPrescaler = 1;
hfdcan1.Init.DataSyncJumpWidth = 1;
hfdcan1.Init.DataTimeSeg1 = v4;
hfdcan1.Init.DataTimeSeg2 = v5;
hfdcan1.Init.MessageRAMOffset = 0;
hfdcan1.Init.StdFiltersNbr = 0;
hfdcan1.Init.ExtFiltersNbr = 0;
hfdcan1.Init.RxFifo0ElmtsNbr = 24;
hfdcan1.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8;
hfdcan1.Init.RxFifo1ElmtsNbr = 16;
hfdcan1.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8;
hfdcan1.Init.RxBuffersNbr = 0;
hfdcan1.Init.RxBufferSize = FDCAN_DATA_BYTES_8;
hfdcan1.Init.TxEventsNbr = 0;
hfdcan1.Init.TxBuffersNbr = 0;
hfdcan1.Init.TxFifoQueueElmtsNbr = 24;
hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
hfdcan1.Init.TxElmtSize = FDCAN_DATA_BYTES_8;
if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN FDCAN1_Init 2 */
HAL_StatusTypeDef hs;
hs = HAL_FDCAN_ActivateNotification ( &hfdcan1, FDCAN_IE_RF0NE | FDCAN_IE_RF1NE | FDCAN_IE_BOE, 0 );
if (hs != HAL_OK)
{
sprintf ( tmpstr, "HAL_FDCAN_ActivateNotification() returned %d\r\n", ( int )hs );
DbgUart_Transmit_String ( tmpstr );
}
HAL_FDCAN_Start ( &hfdcan1 );
/* USER CODE END FDCAN1_Init 2 */
}
I even changed :
void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs)
{
hfdcan1.Instance->IE |= FDCAN_IE_RF0NE | FDCAN_IE_RF1NE | FDCAN_IE_BOE; // HAL library disables these interrupts every time they occur
if ( hfdcan != &hfdcan1 )
return;
CAN_Read_Incoming_FIFO(hfdcan);
}
to:
void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs)
{
hfdcan1.Instance->IE |= FDCAN_IE_RF0NE | FDCAN_IE_BOE; // HAL library disables these interrupts every time they occur
if ( hfdcan != &hfdcan1 )
return;
CAN_Read_Incoming_FIFO(hfdcan);
}
void HAL_FDCAN_RxFifo1Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo1ITs)
{
hfdcan1.Instance->IE |= FDCAN_IE_RF1NE | FDCAN_IE_BOE; // HAL library disables these interrupts every time they occur
if ( hfdcan != &hfdcan1 )
return;
CAN_Read_Incoming_FIFO(hfdcan);
}
But RX FIFO 1 callback never triggers.
I also observe during CAN Init function HAL_FDCAN_ConfigFilter() is not called.
I would like to use all available FIFOs (and its filters) to accept Receive CAN messages and ifpossible to use both RX FIFO 0 and RX FIFO 1.
Please suggest how to achieve this assuming my I have only unique 4 Extended filters and masks which help come up with resulting value of 0x002B0000, 0x00AC0000, etc.
Regards,
Rajeev
2024-03-06 09:03 PM
Dear @Khouloud ZEMMELI , @Imen.D ,
Please connect me with someone who can help resolve the shared concern.
Regards,
Rajeev