Skip to main content
Explorer II
September 15, 2024
Solved

FDCAN not working with STM32U5F7

  • September 15, 2024
  • 12 replies
  • 4444 views

I'm using a custom board with an STM32U5F7. Written a program(with nothing else configured other than clock and FDCAN) that simply sends out a message via FDCAN (in classis mode, 500kbps) which I'm hoping to receive using a P-CAN. When probing the TX line going to my transceiver using an oscilloscope there seems to be no data being transmitted, the line is just pulled high to 3V3. 

 

The same board populated with an STM32U599 running a new project with the same configuration and same code is able to successfully send messages which I can scope on the TX line.

 

With the STM32U5F7, I have tried internal loopback mode to rule out any hardware related issues (following the FDCAN loopback walkthrough on ST's YouTube) but I'm not receiving messages as well.

 

Not sure what to make of this or how to diagnose and fix the issue I'm facing any further than this. Any input would be highly appreciated 

    This topic has been closed for replies.
    Best answer by mƎALLEm

    Hello @Hareesh_S ,

    Another customer faced an issue with FDCAN with the same part number.

    After an internal task force, it turns out that STM32U5F7 part number doesn't support FDCAN. It's disabled by hardware. 

    What we propose is to use STM32U5G7 part number instead.

    Sorry for any inconvenience.

    12 replies

    Technical Moderator
    September 15, 2024

    Hello @Hareesh_S and welcome to the ST community.

    As loopback is not working, are you sure about the filter config?

    If possible to attach your project including the ioc file.

    Hareesh_SAuthor
    Explorer II
    September 16, 2024

    Hello,
    I've attached my project file below, including the IOC file - this project is curently setup to use external loopback, but I tried internal prior to it, with no avail.
    With regards to filter config - I'm not exactly sure myself - which is why my initial test for bring-up was only to send out messages from my board, discarding the need of filter configuration in the first place. Regardless, for loopback mode, I have copied the filter configuration from tutorials I was following - though I have omitted seemingly deprecated code.

    Thank you for your reply!
    (And apologies for the delay in mine - time zone differences)

    Technical Moderator
    September 16, 2024

    Hello,

    1- You configured your CAN interface in Classic mode, while you are transmitting frames in FD mode:

    hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC;

    And you are transmitting data in FD mode

    TxHeader.FDFormat = FDCAN_FD_CAN;

    So change it to FDCAN_CLASSIC_CAN.

    2- Data lenght needs to be =< 8 but your DLC is set to 12:

    TxHeader.DataLength = FDCAN_DLC_BYTES_12;

     So, change it to 8.

    Hareesh_SAuthor
    Explorer II
    September 16, 2024

    Hello,

    Not sure what happened there, was trying to botch together an example project to send and messed up a few things.
    I have made the corrections you have highlighted, but still don't see anything in my RXData buffer.

    Do you find anything else wrong in the project I have attached? Reattaching with the changes made for clarity.

    I have another project that only sends CAN messages (the code and config for which I know works with the STM32U599, but isn't with the STM32U5F7. Should I attach that project as well?)

    Thank you for your reply

    Technical Moderator
    September 16, 2024

    Hello,

    You are using Interrupts/callback, but you didn't activate the RXFIFO notification interrupt:

    Add this line after HAL_FDCAN_ConfigFilter()

     

    HAL_FDCAN_ActivateNotification(&hfdcan1, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0);

     

    And no need to activate this notification in the callback as you did:

     

    void HAL_FDCAN_RxFifo0Callback(FDCAN_HandleTypeDef *hfdcan, uint32_t RxFifo0ITs) {
    	if ((RxFifo0ITs & FDCAN_IT_RX_FIFO0_NEW_MESSAGE) != RESET) {
    		/* Retrieve Rx messages from RX FIFO0 */
    		if (HAL_FDCAN_GetRxMessage(hfdcan, FDCAN_RX_FIFO0, &RxHeader, RxData)
    				!= HAL_OK) {
    			Error_Handler();
    		}
    		if (HAL_FDCAN_ActivateNotification(hfdcan,
    		FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0) != HAL_OK) {
    			Error_Handler();
    		}
    	}
    }

     

    Hareesh_SAuthor
    Explorer II
    September 16, 2024

    Hello,
    I have made the changes you have pointed out, including a screenshot as I think it would be easier for you to access, given that I have not changed anything else. I am still not getting any data in my RXData buffer though.

    Hareesh_S_0-1726488262902.png

    Hareesh_S_1-1726488301745.png

     

    I appreciate your patience in assisting me solve my issues,
    Thank you!

    Technical Moderator
    September 16, 2024

    Hello,

    First, please don't use screeshots to show your code. You need just to paste your code using </> button.

    Second, unfortunately I don't have a STM32U5F7 board to test.

    Try to change the filter config either:

    By replacing:

    sFilterConfig.FilterType = FDCAN_FILTER_MASK;

    by:

    sFilterConfig.FilterType = FDCAN_FILTER_DUAL;

     or keeping filter mask config and replace:

    	sFilterConfig.FilterID2 = 0x11;

    by:

    sFilterConfig.FilterID2 = 0x7FF;

     

    Hareesh_SAuthor
    Explorer II
    September 16, 2024

    Hello

    1) Apologies, I will keep in mind henceforth to avoid screenshots.
    2) Tried both suggestions, isn't working.
    3) I think it would be more productive at this point if instead of loopback, we simply try sending out a CAN message instead, since I have access to an oscilloscope and a P-CAN and can verify if it is functioning as intended + it removes any extra variables from the equation.

    I have attached a project below that only sends out a standard CAN message every 100ms. If you don't mind, please check this one out.

    Thanks again

    Technical Moderator
    September 16, 2024

    @Hareesh_S wrote:

    3) I think it would be more productive at this point if instead of loopback, we simply try sending out a CAN message instead, 


    I don't recommend that. If you didn't succeed in loopback mode, I don't think you can succeed with Normal mode.

    As you have an oscilloscope, and with external loopback mode do you get any frame on CAN_Tx?

    Hareesh_SAuthor
    Explorer II
    September 16, 2024

    That's fair.
    And no, I do not get any frame on CAN_Tx with external loopback mode - the pin is just held at VCC. 

    Hareesh_SAuthor
    Explorer II
    September 16, 2024

    Yes, the board I am using allocates PB8 and PB9 to CAN lines, and test points are provided for the same, which is where I am checking. I can indeed confirm I am probing the right pin as I have tried configuring PB9 as a PWM output to see if is able to toggle at 500KHz, which it is able to cleanly.

    The Tx and Rx lines have an external pull up to 3V3, which is why I have not set them as high by default. I have tried by removing the external pull up as well, to no avail.

    Technical Moderator
    September 16, 2024

    That's weird..

    Did you change the GPIO speed to High?

    Hareesh_SAuthor
    Explorer II
    September 16, 2024

    I have not tried this actually, I assumed it was not the issue since it wasn't causing me issues with the U599. I will try this out and get back at the earliest. Thanks! 

    Hareesh_SAuthor
    Explorer II
    September 17, 2024

    Hello again.

    I can confirm that changing GPIO speeds does not work. Pins are set to "Very High" now, no difference in behaviour.

    Technical Moderator
    September 17, 2024

    Hello,

    Just tested the project on a compatible MCU (on STM32U5G9 DK board) I've just adapted the value of crystal 25MHz -> 16MHz and it's working perfectly. The Rx callback is raising and the data are receiving very well.

    This is the Live Expression and as you can see the value is updating. Just added the incrementation of the first data TxData[0]:

    SofLit_0-1726579543668.png

    See attached project. So need to check again from your side.

    Hope I answered your question.

     

    Hareesh_SAuthor
    Explorer II
    September 17, 2024

    Hello,

    Thank you for attaching a working example. I tried running the same project (only changed the clock source as I have a 32Mhz osc instead) but it is not working.
    Given that this is testing internal loopback, is it safe for me to assume the specific MCU I have is just faulty? Not sure how else to proceed at this point.

    Technical Moderator
    September 17, 2024

    @Hareesh_S wrote:

    Given that this is testing internal loopback, is it safe for me to assume the specific MCU I have is just faulty? 


    At this point I can't add more as I don't have the same MCU part number as yours. But there is no difference between the two MCUs from FDCAN stand point.

    Hareesh_SAuthor
    Explorer II
    September 17, 2024

    That's completely fair. Thank you for your guidance thus far, I'll try  with another board/MCU and see if I can figure something out from my end