2023-12-28 02:15 AM - last edited on 2024-01-03 05:05 AM by Mike_ST
I am trying to write code for a simple transmit and receive in FDCAN (Classic Mode) in external loopback mode, but I have been unsuccessful in doing so. I don't even know where I am going wrong and am looking for help as my last resort.
I have tried using the MCP2551 CAN trasceiver and also without, as I am unsure whether the NUCLEO H7A3ZI-Q has an inbuilt transceiver or not. Whenever I try to run my code, the TxBufferMessagePending starts facing errors.
Also, I wanted to know, if a transceiver is required for CAN interface, is it possible on a CAN transceiver like the MCP2551 or do I require a seperate CANFD transceiver.
Please find attached .ioc file and main.c code for my STM Project.
Solved! Go to Solution.
2024-01-10 06:21 AM - edited 2024-01-12 06:42 AM
Hello,
I've ported the example https://github.com/STMicroelectronics/STM32CubeH7/tree/master/Projects/STM32H7B3I-EVAL/Examples/FDCAN/FDCAN_Loopback to STM32H7A3ZI-Q Nucleo board for you with some modifications mainly it's working with Classic format @500kB/s.
See attached project.
Hope it helps.
EDIT: fixed the issue of data bytes number (12 -> 8 )
2024-01-08 06:41 AM
Hello,
Loopback mode doesn't need an external transceiver. Only normal mode does.
Try to configure the Pull-up/Pull-down of the CAN_Rx pin (PB5 in you case) as Pull-up.
2024-01-09 02:54 AM
Thank you for your reply.
However after doing the required changes, I am still facing the same issue.
I would like to know what exactly does changing the GPIO to Pull-Up mode will do.
2024-01-09 05:09 AM
Thank you for your reply.
However after doing the required changes, I am still facing the same issue.
I would like to know what exactly does changing the GPIO to Pull-Up mode will do.
2024-01-09 07:39 AM
Hello,
It was a tentative to help you as the pull-up resistor is needed in bxCAN.
Now if it does not solve the issue it should be analyzed deeper..
Did you try to port the example: https://github.com/STMicroelectronics/STM32CubeH7/tree/master/Projects/STM32H7B3I-EVAL/Examples/FDCAN/FDCAN_Loopback to your Nucleo board?
2024-01-09 08:16 AM - edited 2024-01-09 09:37 AM
For CAN bus you always need a transceiver, maybe mcp2551.
+
For a first test, try internal loopback.
If this is working, you can try external loopback, but maybe need set pullup on Tx pin,
or have real transceiver connected, with termination.
2024-01-09 12:48 PM
I don't see that you call HAL_FDCAN_ConfigGlobalFilter or HAL_FDCAN_ActivateNotification in your code?
2024-01-10 06:21 AM - edited 2024-01-12 06:42 AM
Hello,
I've ported the example https://github.com/STMicroelectronics/STM32CubeH7/tree/master/Projects/STM32H7B3I-EVAL/Examples/FDCAN/FDCAN_Loopback to STM32H7A3ZI-Q Nucleo board for you with some modifications mainly it's working with Classic format @500kB/s.
See attached project.
Hope it helps.
EDIT: fixed the issue of data bytes number (12 -> 8 )
2024-01-11 05:15 AM - edited 2024-01-11 05:23 AM
Hello,
Thank You for your code, but I am not able to see received values in RxData under Live Expressions. So I am unsure if the code actually worked or not for me.
If you could kindly elaborate what I am missing here.
Also, I noticed that you are trying to send 12 bytes of data through FDCAN in Classic mode. Doesn't it support a max data frame of only 8 bytes?
2024-01-11 06:14 AM - edited 2024-01-11 07:32 AM
Hello,
Indeed it should be 8Bytes max. It was a mistake, replace 12 by 8.
I said I ported this example https://github.com/STMicroelectronics/STM32CubeH7/tree/master/Projects/STM32H7B3I-EVAL/Examples/FDCAN/FDCAN_Loopback, So please read the readme file to understand how it works.
To launch the communication, press the user button. Put RxData in the live watch. There are Three messages to send and receive.