Skip to main content
jgauthier
Senior
May 6, 2022
Question

FDCAN RX interrupt not firing

  • May 6, 2022
  • 1 reply
  • 2226 views

Hello,

I'm trying to set up an interrupt when my FDCAN controller received a CAN message. MCU is an STM32G0B1

I went into STCubeMX and I enabled these interrupts:

0693W00000NpVcLQAV.pngThis generated some new functions instm32g0xx_it.c:

void TIM16_FDCAN_IT0_IRQHandler(void)
{
/* USER CODE BEGIN TIM16_FDCAN_IT0_IRQn 0 */
 
/* USER CODE END TIM16_FDCAN_IT0_IRQn 0 */
HAL_FDCAN_IRQHandler(&hfdcan1);
/* USER CODE BEGIN TIM16_FDCAN_IT0_IRQn 1 */
 
/* USER CODE END TIM16_FDCAN_IT0_IRQn 1 */
}
 
/**
* @brief This function handles TIM17, FDCAN1_IT1 and FDCAN2_IT1 Interrupt.
*/
void TIM17_FDCAN_IT1_IRQHandler(void)
{
/* USER CODE BEGIN TIM17_FDCAN_IT1_IRQn 0 */
 
/* USER CODE END TIM17_FDCAN_IT1_IRQn 0 */
HAL_FDCAN_IRQHandler(&hfdcan1);
/* USER CODE BEGIN TIM17_FDCAN_IT1_IRQn 1 */
 
/* USER CODE END TIM17_FDCAN_IT1_IRQn 1 */
}

This appears to call this function for RX FIFO on 0 and 1

 /* Rx FIFO 0 interrupts management ******************************************/
if (RxFifo0ITs != 0U)
{
/* Clear the Rx FIFO 0 flags */
__HAL_FDCAN_CLEAR_FLAG(hfdcan, RxFifo0ITs);
 
#if USE_HAL_FDCAN_REGISTER_CALLBACKS == 1
/* Call registered callback*/
hfdcan->RxFifo0Callback(hfdcan, RxFifo0ITs);
#else
/* Rx FIFO 0 Callback */
HAL_FDCAN_RxFifo0Callback(hfdcan, RxFifo0ITs);
#endif /* USE_HAL_FDCAN_REGISTER_CALLBACKS */
}
 
/* Rx FIFO 1 interrupts management ******************************************/
if (RxFifo1ITs != 0U)
{
/* Clear the Rx FIFO 1 flags */
__HAL_FDCAN_CLEAR_FLAG(hfdcan, RxFifo1ITs);
 
#if USE_HAL_FDCAN_REGISTER_CALLBACKS == 1
/* Call registered callback*/
hfdcan->RxFifo1Callback(hfdcan, RxFifo1ITs);
#else
/* Rx FIFO 1 Callback */
HAL_FDCAN_RxFifo1Callback(hfdcan, RxFifo1ITs);
#endif /* USE_HAL_FDCAN_REGISTER_CALLBACKS */
}

I enabled interrupts after "HAL_FDCAN_Start(&hfdcan1);"

		HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0);
HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_RX_FIFO1_NEW_MESSAGE, 0);

(These both return HAL_OK, but I have also tried just using FDCAN_IT_RX_FIFO0_NEW_MESSAGE and not FDCAN_IT_RX_FIFO1_NEW_MESSAGE)

 

I then created the callback functions:

void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs) {
serprintf("int0\n\r");
}
 
void HAL_FDCAN_RxFifo1Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs) {
serprintf("int1\n\r");
}

They don't do anything except confirm being called.

 

I put breakponts at "HAL_FDCAN_IRQHandler(&hfdcan1);" for both functions, "void TIM16_FDCAN_IT0_IRQHandler(void)" and "void TIM17_FDCAN_IT0_IRQHandler(void)"

and neither of these functions get called when receiving a CAN message.

 

I'm not sure that I missed something. Any pointers?

 

 

 

 

This topic has been closed for replies.

1 reply

mƎALLEm
ST Technical Moderator
September 23, 2026

Hello,

I suspect you didn’t set the filter number according to the IDs received and you kept them zeroed:

If all the FDCAN is OK and the filter number = 0 you’ll never receive anything. So you need to set the filter number > 0.

You can also refer to the knowledge base article:

It’s already using STM32G0B1RE MCU with interrupt mode.

Hope that helps you as well as others ..

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.