cancel
Showing results for 
Search instead for 
Did you mean: 

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

vrushalighorpade
Associate II

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

8 REPLIES 8
Saket_Om
ST Employee

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.

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Omar
SofLit
ST Employee

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 on "Accept as Solution" on the reply which solved your issue or answered your question.

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. 

Hi,

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

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

 

 

Hello,

As you are using Classic mode, no need to configure data timings, but you need to configure the number of filters.

Could you please attach your project?

Other questions: 

As you are using TCAN1044 transceiver, does it have VIO pin? How did you connect it?

Do you have 120 ohm termination resistors at both sides of the bus?

Could you please show your schematics?

 


To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Karl Yamashita
Lead III

Test in loopback mode.

If it works then it's hardware issue. If it doesn't work, then something in your code.

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.

Hello @vrushalighorpade ,

Could you please state on this thread please? did you solve your issue?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.