cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H743VI FDCAN didn't works as classical CAN

LSH
Associate II

Hello, I have some trouble with FDCAN.

Please let me know what is wrong with my settings.

 

1. Current problem

: My STM32H7 transmit only error.

LSH_6-1707659672665.png (Logic Analyzer)

LSH_0-1707657852549.png (PCAN View)

Same error signal repeat endless and if I connect PCAN, many other error and stuff error occur and can bus status become BUSHEAVY.

 

I check where does HAL_FDCAN_AddMessageToTxFifoQ() return HAL_ERROR.

First transmission, HAL_FDCAN_AddMessageToTxFifoQ() return HAL_OK(but in Logic analyzer and PCAN, it is just error) and in Second transmission, TXFQS is 0x00 20 00 00 and enter a if state under and return HAL_ERROR.

LSH_5-1707659199679.png

I think it is become there was no ACK from PCAN. Therefore Tx Que in STM32 will not reset.

Maybe PCAN can't give ACK to STM32 because STM32 didn't transmit hole CAN frame as you can see upper logic analyzer screenshot.

 

2. How I test CAN communication.

LSH_1-1707658358071.png

This is what I setup for debugging.

* I didn't attach 120 Ohm terminal resistor because length of CAN bus is short. (it is shorter than 50cm.)

 

3. Current setting.

3.1 Bit timming and HW settings

LSH_4-1707658542544.png

I am using 12MHz for CANbus from HSE(12MHz TCXO) and SN65HVD231Q-Q1 CAN transceiver.

LSH_3-1707658484620.png

I follow this settings. Under code is in main.c -> static void MX_FDCAN2_Init(void)

  hfdcan2.Init.NominalPrescaler = 1;

  hfdcan2.Init.NominalSyncJumpWidth = 3;

  hfdcan2.Init.NominalTimeSeg1 = 20;

  hfdcan2.Init.NominalTimeSeg2 = 3;

 

  hfdcan2.Init.DataPrescaler = 1;

  hfdcan2.Init.DataSyncJumpWidth = 3;

  hfdcan2.Init.DataTimeSeg1 = 20;

  hfdcan2.Init.DataTimeSeg2 = 3;

 

3.2 other settings (Under code is in main.c -> static void MX_FDCAN2_Init(void))

hfdcan2.Instance = FDCAN2;

hfdcan2.Init.FrameFormat = FDCAN_FRAME_CLASSIC;

hfdcan2.Init.Mode = FDCAN_MODE_NORMAL;

hfdcan2.Init.AutoRetransmission = ENABLE;

hfdcan2.Init.TransmitPause = DISABLE;

hfdcan2.Init.ProtocolException = DISABLE;

 

hfdcan2.Init.MessageRAMOffset = 0;

hfdcan2.Init.StdFiltersNbr = 1;

hfdcan2.Init.ExtFiltersNbr = 1;

hfdcan2.Init.RxFifo0ElmtsNbr = 1;

hfdcan2.Init.RxFifo0ElmtSize = FDCAN_DATA_BYTES_8;

hfdcan2.Init.RxFifo1ElmtsNbr = 0;

hfdcan2.Init.RxFifo1ElmtSize = FDCAN_DATA_BYTES_8;

hfdcan2.Init.RxBuffersNbr = 0;

hfdcan2.Init.RxBufferSize = FDCAN_DATA_BYTES_8;

hfdcan2.Init.TxEventsNbr = 0;

hfdcan2.Init.TxBuffersNbr = 0;

hfdcan2.Init.TxFifoQueueElmtsNbr = 1;

hfdcan2.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;

hfdcan2.Init.TxElmtSize = FDCAN_DATA_BYTES_8;

 

--------------------------------------------------------------------------------------------------------

I already check example on github and AN5348 document but I can't find why it didn't work. (actually, I don't know lot about memory system in STM32.)

I attach my main.c file and ioc file.

If you know how to use classic CAN. please help me.

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello,

CAN_H line is not changing in the screenshot you provide. Could you please check?

Also, I suggest to add 2x120 ohms on the line even the length is short (just for the test).

 

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

5 REPLIES 5
SofLit
ST Employee

Hello,

CAN_H line is not changing in the screenshot you provide. Could you please check?

Also, I suggest to add 2x120 ohms on the line even the length is short (just for the test).

 

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.
SofLit
ST Employee

Also could you please increase the system clock using PLL (for example @120MHz)and keep FDCAN clock source as HSE? (just for the test)

SofLit_0-1707745431787.png

Could you also share your transceiver datasheet?

 

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.
SofLit
ST Employee

Hello,

I did some tests playing with system clock and FDCAN kernel clock and this is a table summarizing the results:

SofLit_1-1707843447437.png

I don't recommend you configuration. 

To be safe choose FDCAN kernel clock less or equal than Sys clk / 2 

 

 

 

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.
SofLit
ST Employee

Attached a project from which I got these results.

Details:

  • Using H743 NUCLEO board 
  • FDCAN in Classical mode
  • Loopback mode is used
  • PLL1 used for system clock
  • PLL2 as source for FDCAN ker clock

 

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.
LSH
Associate II

Thank you so much.

 

I get some hint from your first suggestion(CAN H is not changing) and I found there was 330Ohm resistor between CAN transceiver and MCU. It increase RC constant of signal line. I delete this 330 Ohm resistor and add 120 Ohm termination resistor. These actions make CAN works!

I increase system clock to 75MHz too.

 

Thank you again!