Skip to main content
Visitor II
October 6, 2024
Question

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

  • October 6, 2024
  • 3 replies
  • 2548 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

    This topic has been closed for replies.

    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.

    Visitor II
    October 10, 2024

    Hi,

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

    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.

    Visitor II
    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. 

    Visitor II
    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

     

     

    Graduate II
    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.