Skip to main content
Shubh150
Associate II
December 28, 2023
Solved

STM32H7A3ZI-Q FDCAN TxBufferMessagePending Error.

  • December 28, 2023
  • 4 replies
  • 3069 views

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.

Best answer by mƎALLEm

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  )

4 replies

mƎALLEm
Technical Moderator
January 8, 2024

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.

SofLit_0-1704724827094.png

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Shubh150
Shubh150Author
Associate II
January 9, 2024

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.

mƎALLEm
Technical Moderator
January 9, 2024

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?

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Shubh150
Shubh150Author
Associate II
January 9, 2024

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.

AScha.3
Super User
January 9, 2024

For CAN bus you always need a transceiver, maybe mcp2551.

+

For a first test, try internal loopback.

AScha3_0-1704816791058.png

If this is working, you can try external loopback, but maybe need set pullup on Tx pin,

or have real transceiver connected, with termination.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Karl Yamashita
Principal
January 9, 2024

I don't see that you call HAL_FDCAN_ConfigGlobalFilter or HAL_FDCAN_ActivateNotification in your code?

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source