Skip to main content
Graduate
July 22, 2024
Solved

FDCAN interrupt not working

  • July 22, 2024
  • 4 replies
  • 4548 views

Hello,

 

I am trying to use FDCAN but for some reason interrupt is not triggering. Im using PEAK CAN to send and recieve messages. With osciloscope I can see the data being transfared to the STM board but the interrupt doesn't trigger. The speed I want is 125 kbit/s . I've done this with the CAN before but with FDCAN just cant seem to figure it out.

I have enabled FDCAN1 interupt 0 in the NVIC with priority 5.

Any idea what should I check? I have a feeling that it might be the filter settings that are wrong but Im just not sure.

 

 

 

I've tried sending data to 0x11 and 0x22 but nothing happens. 

PPopo1_0-1721635882543.png

 

Filter and fdcan setup:

 

 

 

 

 

/* USER CODE END FDCAN1_Init 1 */
 hfdcan1.Instance = FDCAN1;
 hfdcan1.Init.ClockDivider = FDCAN_CLOCK_DIV1;
 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 = 12;
 hfdcan1.Init.NominalSyncJumpWidth = 1;
 hfdcan1.Init.NominalTimeSeg1 = 13;
 hfdcan1.Init.NominalTimeSeg2 = 2;
 hfdcan1.Init.DataPrescaler = 24;
 hfdcan1.Init.DataSyncJumpWidth = 1;
 hfdcan1.Init.DataTimeSeg1 = 13;
 hfdcan1.Init.DataTimeSeg2 = 2;
 hfdcan1.Init.StdFiltersNbr = 1;
 hfdcan1.Init.ExtFiltersNbr = 1;
 hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
 if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK)
 {
 Error_Handler();
 }
 /* USER CODE BEGIN FDCAN1_Init 2 */

 //FDCAN1 FILTER

 FDCAN_FilterTypeDef sFilterConfig;

 sFilterConfig.IdType = FDCAN_STANDARD_ID; // Use standard IDs
 sFilterConfig.FilterIndex = 0; // Filter index 0
 sFilterConfig.FilterType = FDCAN_FILTER_DUAL; // Use range filter
 sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0; // Route accepted messages to RX FIFO 0
 sFilterConfig.FilterID1 = 0x11; // Start of ID range
 sFilterConfig.FilterID2 = 0x22; // End of ID range (standard ID max is 0x7FF)
 if (HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig) != HAL_OK)
 {
 /* Filter configuration Error */
 Error_Handler();
 }

 

 

 

 

 

FDCAN defines:

 

 

 

 

 

 		// Configure TX Header for FDCAN1
 		TxHeader1.Identifier = 0x11;
 		TxHeader1.IdType = FDCAN_STANDARD_ID;
 		TxHeader1.TxFrameType = FDCAN_DATA_FRAME;
 		TxHeader1.DataLength = FDCAN_DLC_BYTES_12;
 		TxHeader1.ErrorStateIndicator = FDCAN_ESI_ACTIVE;
 		TxHeader1.BitRateSwitch = FDCAN_BRS_OFF;
 		TxHeader1.FDFormat = FDCAN_FD_CAN;
 		TxHeader1.TxEventFifoControl = FDCAN_NO_TX_EVENTS;
 		TxHeader1.MessageMarker = 0;

 

 

 

 

 

Callback function:

 

 

 

 

 

// FDCAN1 Callback
void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs)
{
 if((RxFifo0ITs & FDCAN_IT_RX_FIFO0_NEW_MESSAGE) != RESET)
 {
 /* Retreive Rx messages from RX FIFO0 */
 if (HAL_FDCAN_GetRxMessage(hfdcan, FDCAN_RX_FIFO0, &RxHeader1, RxData1) != HAL_OK)
 {
 /* Reception Error */
 Error_Handler();
 }

 if (HAL_FDCAN_ActivateNotification(hfdcan, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0) != HAL_OK)
 {
 /* Notification Error */
 Error_Handler();
 }
 }
}

 

 

 

 

 

 

 

 

    This topic has been closed for replies.
    Best answer by PPopo.1

    So the solution was that when running sys tick with TIM 6 you have to change priority from 15 (default) to something lower otherwise it wont work... Also ControllersTech example tutorial and also older version of STM32 examples are not mentioning GLOBAL FILTER, which you also have to use.

    4 replies

    Technical Moderator
    July 22, 2024

    Hello,

    You didn't tell what product you are using?

    I suggest first to start with Loopback mode before Normal mode to discard any connection or HW issues.

    See also this article.

    PPopo.1Author
    Graduate
    July 22, 2024

    I am using STM32H7S7L8 discovery board. Good idea, Ill get back to you after I do that.

    PPopo.1Author
    Graduate
    July 22, 2024

    Okay thank you. This is the project. It should be pretty simple since I followed the controllerstech tutorial.

    Technical Moderator
    July 22, 2024

    Thank you. Where is the ioc file? could you please repackage the zip with the ioc file?

    PPopo.1Author
    Graduate
    July 22, 2024

    Im sorry, TouchGFX auto generates it outside of the STM32cubeIDE folder, didn't even notice.

     

    Technical Moderator
    July 22, 2024

    Ah! you are running TouchGFX!

    I suggest you to create a very simple project with a very basic CAN communication in Loopback mode: without any middleware: FreeRTOS, TouchGFX etc .. So I will look at it after. Just an example like we provide in STM32Cube examples: https://github.com/STMicroelectronics/STM32CubeH7/tree/master/Projects/STM32H743I-EVAL/Examples/FDCAN/FDCAN_Loopback

    PPopo.1Author
    Graduate
    July 23, 2024

    Yes, sorry for not mentioning earlier. I have created a new project, where I'm trying to use only FDCAN. I have the same issue as before. Also no data transmission is being detected with osciloscope.

    EDIT: interrupt is not being called therefore rx callback is not executed. I tried adding TxFifoCallback, which is also not being called.

    Since it's not sending data, the FIFO gets full and enters erro handle state.

     

    PPopo.1AuthorAnswer
    Graduate
    August 14, 2024

    So the solution was that when running sys tick with TIM 6 you have to change priority from 15 (default) to something lower otherwise it wont work... Also ControllersTech example tutorial and also older version of STM32 examples are not mentioning GLOBAL FILTER, which you also have to use.