Skip to main content
Associate
October 6, 2024
Question

Not able to transmit and receive CAN frames using CANFD classic mode on STM32G0B1CBT3

  • October 6, 2024
  • 3 replies
  • 5462 views

Hi,

I am using STM32G0B1CBT3 controller and would like to send and receive data in classic mode. I have configured all necessary parameters using cubemx but the buffer is getting full when I call this function HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &TxHeader, TxData).

The CAN termination is connected properly.

Following are my configuration settings:

ClockConfig1.jpeg

clock.jpeg

FDCANClock.jpeg

CANConfig.jpeg

basicparameter.jpeg

500kbps.jpeg

3 replies

Technical Moderator
October 8, 2024

Hello @vrushalighorpade,

For your application, I recommend referring to the example located at Projects/STM32G0C1E-EV/Examples/FDCAN/FDCAN_Classic_Frame_Networking.  It includes a .ioc file for STM32CubeMX, allowing you to easily customize the configuration to suit your specific needs.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om
Associate
October 10, 2024

Hi,

I have  modified .ioc file example file based on my requirement but no success.

mƎALLEm
Technical Moderator
October 8, 2024

Hello @vrushalighorpade and welcome to the community,

As per your main.c, you are using Normal mode:

 

 hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;

 

1- What board are you using? custom or ST board example: NUCLEO-G0B1?

2- Are you using a CAN transceiver?

3- Did you connect another CAN node on the bus?

4- This CAN timing is not optimized for good operation:

 

 hfdcan1.Init.NominalPrescaler = 16;
 hfdcan1.Init.NominalTimeSeg1 = 3;
 hfdcan1.Init.NominalTimeSeg2 = 4;

 

Your sample point needs to be between 75% and 85%. So please decrease the prescaler as much as possible and increase BS1 and BS2 in such way: BS1 ~= (75% to 85%)x(BS1+BS2).

Please also review this article.

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

Thank You for your reply. Now buffer overflow error is solve by making changes in transceiver but still I am experiencing CAN frame receive and transmit issue.

Not able to transmit and receive CAN frames using CANFD classic mode on STM32G0B1CBT3 

Following are the answers for your questions

1- What board are you using? custom or ST board example: NUCLEO-G0B1?

Ans : I am using custom Board with STM32G0B1CBT3

2- Are you using a CAN transceiver? 

Ans : Yes, TCAN1044AVDRQ1e

3- Did you connect another CAN node on the bus?

Ans : At another end I have connected PCAN USB adapter and checking CAN messages on Busmaster/PCAN View

4- This CAN timing is not optimized for good operation:

Ans : Tried to optimize the prescaler but no success.

Anything else am I missing?

Thank You. 

Associate
October 10, 2024

As I am using normal mode and classic frame format is it necessary to configure following parameters for normal mode as well?

vrushalighorpade_0-1728583993196.png

 

 

Karl Yamashita
Lead III
October 11, 2024

Test in loopback mode.

If it works then it's hardware issue. If it doesn't work, then something 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