【NUCLEO H533RE】CAN FD function and communication test
[Copy link]
This post was last edited by bigbat on 2024-8-17 12:59
1. Test introduction
This test is to test how to configure the NUCLEO-H533RE FDCAN peripheral to adapt to different CAN bit rate communication reception using restricted mode. The NUCLEO-H563ZI board is used in the communication. The NUCLEO-H563Z is responsible for data transmission. The routine "FDCAN_Adaptive_Bitrate_Transmitter" that comes with the NUCLEO-H563ZI development board is used. The NUCLEO-H533RE development board is responsible for reception. The TJA1050 controller module is used as the CAN transceiver module.
2. Hardware connection configuration
VCC 3.3V, GND pin
FDCAN RX pin PD0 of NUCLEO-H563ZI <==> TJA1050 module 1 TX
FDCAN TX pin PD1 of NUCLEO-H563ZI <==> TJA1050 module 1 RX
VCC 3.3V, GND pin
FDCAN RX pin PA11 of NUCLEO-H533RE <==> TJA1050 module 2 TX
FDCAN TX pin PA12 of NUCLEO-H533RE <==> TJA1050 module 2 RX
TJA1050 module 1 and TJA1050 module 2
TJA1050 module 1 CANFDH <==> TJA1050 module 2 CANFDH
TJA1050 module 1 CANFDL <==> TJA1050 module 2 CANFDL
3. Parameter configuration
NUCLEO-H533RE Clock Configuration
The system uses an external 24M crystal oscillator, and the system clock is 250MHZ
FD CAN parameter configuration
GPIO pins use PA11 and PA12 pins. For parameters, refer to FD CAN parameter settings of NUCLEO-H563ZI.
Turn on interrupt FDCAN1 0 interrupt.
4. Program Analysis
The program code refers to the code transplantation of the example "FDCAN_Adaptive_Bitrate_Receiver". LED1 in the program is rewritten as LED_GREEN. For detailed code, please refer to the attachment.
The program is divided into several steps:
In the first step, the HAL_FDCAN_Init() function is called to configure the bit rate to try to receive messages from the transmitter board.
Then the receive filter is configured using HAL_FDCAN_ConfigFilter() and the FDCAN module is started using HAL_FDCAN_Start().
The application tries to receive a valid message and if no message is received, this step is repeated with another bit rate.
If all bit rates are tested and no message is received, the application ends and LED3 flashes.
In the second step, the application exits the restricted operation mode using HAL_FDCAN_ExitRestrictedOperationMode().
In the third step, the development board sends a confirmation message to the transmitter development board using HAL_FDCAN_AddMessageToTxFifoQ().
If the result is OK, the application ends and LED1 remains on.
5. Testing process
This test has gone through many attempts, but has not been successfully passed. I don’t know why.
First, program the FDCAN_Adaptive_Bitrate_Transmitter program to NUCLEO-H563ZI and confirm that the program runs normally. Start testing NUCLEO-H533RE
(1) Set a breakpoint at the HAL_FDCAN_RxFifo0Callback() function.
The program cannot execute to the breakpoint. Prove that no break was caused.
(2) The bitrate_found breakpoint is only executed once
The program was run only once before it failed.
6. Test summary
This test has been improved many times, but it cannot pass. I don't know why.
|