cancel
Showing results for 
Search instead for 
Did you mean: 

FDCAN Classical STM32G473 not working with canBus

DiogoPedrosa
Associate III

Hey I am having trouble tryng to connect my stm32g473 to a canbus. I am using a l9616 as a transceiver and the bus is functions as I have connected to it with an stm32f722re with the same l9616.

The clock is 64Mhz,Ive used the canbit time calculation website to define the values of nominal time 1 and 2 to achive 500kbs.

Also using NVIC and it seems to be configured fine. When tested in loopback the interrupt is called and the messages are received.

This is the init with the filter config,as I ve understand I am not filtering anything and any of the messages on the bus should get to my uC.

When running the state of hfdcan1 is Busy and also no error code show up.

FDCAN_HandleTypeDef hfdcan1;

/* FDCAN1 init function */
void MX_FDCAN1_Init(void)
{

  /* USER CODE BEGIN FDCAN1_Init 0 */

  /* USER CODE END FDCAN1_Init 0 */

  /* USER CODE BEGIN FDCAN1_Init 1 */

  /* USER CODE END FDCAN1_Init 1 */
  hfdcan1.Instance = FDCAN1;
  hfdcan1.Init.ClockDivider = FDCAN_CLOCK_DIV1;
  hfdcan1.Init.FrameFormat = FDCAN_FRAME_CLASSIC;
  hfdcan1.Init.Mode = FDCAN_MODE_NORMAL;
  hfdcan1.Init.AutoRetransmission = DISABLE;
  hfdcan1.Init.TransmitPause = DISABLE;
  hfdcan1.Init.ProtocolException = DISABLE;
  hfdcan1.Init.NominalPrescaler = 1;
  hfdcan1.Init.NominalSyncJumpWidth = 1;
  hfdcan1.Init.NominalTimeSeg1 = 111;
  hfdcan1.Init.NominalTimeSeg2 = 16;
  hfdcan1.Init.DataPrescaler = 1;
  hfdcan1.Init.DataSyncJumpWidth = 1;
  hfdcan1.Init.DataTimeSeg1 = 1;
  hfdcan1.Init.DataTimeSeg2 = 1;
  hfdcan1.Init.StdFiltersNbr = 1;
  hfdcan1.Init.ExtFiltersNbr = 0;
  hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
  if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK)
  {
    Error_Handler();
  }

    /* USER CODE BEGIN FDCAN1_Init 2 */
    FDCAN_FilterTypeDef sFilter;

    sFilter.IdType = FDCAN_STANDARD_ID;
    sFilter.FilterIndex = 0;
    sFilter.FilterType = FDCAN_FILTER_MASK;
    sFilter.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;
    sFilter.FilterID1 = 0x000;
    sFilter.FilterID2 = 0x000;  

    if (HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilter) != HAL_OK)
    {
        Error_Handler();
    }

    if (HAL_FDCAN_ConfigGlobalFilter(&hfdcan1,
                                     FDCAN_ACCEPT_IN_RX_FIFO0, 
                                     FDCAN_ACCEPT_IN_RX_FIFO0,  
                                     FDCAN_REJECT_REMOTE,     
                                     FDCAN_REJECT_REMOTE) != HAL_OK)
    {
        Error_Handler();
    }


  /* USER CODE END FDCAN1_Init 2 */

}

Also here is the circuit of the transceiver if that helps,I have 5v stable and gnd on the transceiver itself

 

1 ACCEPTED SOLUTION

Accepted Solutions

@DiogoPedrosa wrote:

About the transceiver,I ve used with many stm32f7 and it worked fine. I will try to search for a substitute but i dont think thats the issue.


If that worked before that doesn't mean it will work forever. You are running out of spec here.. you are at the limit of voltage levels..

If in loopback mode is working but not in normal mode, you have either

- A hardware issue a transceiver issue including the problem I cited previously.. solder joints, connection/wiring etc ..

- Clock issue: not using a precise clock source such as using HSI introducing jitters..

- Bitrate issue: you are not running at the exact CAN bitrate

 

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.

View solution in original post

7 REPLIES 7
mƎALLEm
ST Employee

Hello,

The issue is not clear.

You said:

"Also using NVIC and it seems to be configured fine. When tested in loopback the interrupt is called and the messages are received."

Do you have an issue in Normal mode but not in Loopback mode (you can send and receive CAN frames)? 

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.
mƎALLEm
ST Employee

Looking at the transceiver datasheet:

screenshot.png

VTXO min = 0.7Vs = 0.7x5 = 3.5V > MCU VDD.

That tranceiver is an automotive grade ans it's not compatible with STM32. 

Use a 3.3V transceiver like SN65HVD230 .

 

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.

Yeah the issue happens in normal mode but not in loopback mode. When in loopback I can send packets and receive via nvic.

About the transceiver,I ve used with many stm32f7 and it worked fine. I will try to search for a substitute but i dont think thats the issue.

As testing continued I also changed the can divider to 4 and changed the nominal seg1 and to match my 500kbits/s baud rate.

 

The issue is when in normal mode I cant receive and read any msg.

 

 


@DiogoPedrosa wrote:

About the transceiver,I ve used with many stm32f7 and it worked fine. I will try to search for a substitute but i dont think thats the issue.


If that worked before that doesn't mean it will work forever. You are running out of spec here.. you are at the limit of voltage levels..

If in loopback mode is working but not in normal mode, you have either

- A hardware issue a transceiver issue including the problem I cited previously.. solder joints, connection/wiring etc ..

- Clock issue: not using a precise clock source such as using HSI introducing jitters..

- Bitrate issue: you are not running at the exact CAN bitrate

 

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.

Sure,but wouldnt that be an issue just to send messages? Cause I cant receive any message from the bus,I measured the tx pin with an oscilloscope and it reads a digital signal.

 

I tested another board that I have with an f722re that doesnt support the fdcan paired with the l9616 and it did connect and could receive and transmit messages to the bus,which to me looked like the issue with the stm32g473 was related with the code or maybe something inside the microcontroller related to the fdcan hardware.

 

I already ordered a 3.3v compatible transceiver and should get to me in around 2 weeks. I will come back to comment if that was the solution.



Hello,

Please,

1- Confirm if only STM32G4 and STM32F7 are available as CAN nodes on the bus.

2- Is STM32F7 sending frames to STM32G4 and the latter is not receiving it?

3- Please share your STM32G4 and STM32F7 projects.

 


@DiogoPedrosa wrote:

I already ordered a 3.3v compatible transceiver and should get to me in around 2 weeks. I will come back to comment if that was the solution.


Indeed you need definitely to replace l9616 transceiver.

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.

Okay,just resoldered a new microcontroller and then the canBus started working,maybe I damaged these pins when testing or smth.Anyways now everything works receiveing and transmiting with the l9616.

Still probably gonna change the transceiver to have better relliability.

 My layout is down here just to clarify what was happening.

Appreciate for the help.

Screenshot 2026-03-10 165212.png