cancel
Showing results for 
Search instead for 
Did you mean: 

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

Long1
Visitor

Hi,

I am using STM32G474RET6 controller and would like to send and receive data in classic mode. I have configured all necessary parameters using cubemx but the hard fault occured when I call this function HAL_FDCAN_AddMessageToTxFifoQ(&hfdcan1, &TxHeader, TxData).

The CAN termination is connected properly.

Following are my configuration settings:

Long1_0-1747726536046.png

Long1_1-1747726562403.png

Long1_2-1747726760973.png

i also init the CAN filter before transmit can message using the function below:

Long1_3-1747727087859.png

the can message transmitting function is as below:

Long1_4-1747727184685.png

when the code run till FDCAN_CopyMessageToRAM, it will go into HardFault_Handler, that's really confused me.

disable the code that related to can function in main.c file, it could run normally.

 

 

1 REPLY 1
Long1
Visitor

i have downloaded the example code at  https://github.com/STMicroelectronics/STM32CubeG4/tree/master/Projects/STM32G474E-EVAL/Examples/FDCAN/FDCAN_Classic_Frame_Networking ,but i find that the configuration of FDCAN1 of this example is in FDCAN_MODE_NORMAL, I'm even more confused T^T. Is the example code right?

Long1_0-1747727752568.png