****************** (C) COPYRIGHT 2023 Megawin Technology *******************
* @file CAN/CAN_FDCommunication/readme.txt
* @author Megawin Application Team
* @version V0.0.4
* @date 16-June-2023
* @brief Description of the CAN FDCommunication example.
******************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
* TIME. AS A RESULT, MEGAWIN SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM
* THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
* CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
******************************************************************************
- Example Description
This example describes the use of the controller Local Area Network (CAN) FD standard communication method and how to set the filter of CAN:
In this example, Main clock is from PLL clock and it is configured at 96MHz. The PLL clock is based on 8MHz HSE. APB1 clock is the 2 frequency division of the Main clock, APB2 clock is from Main clock.
CAN peripherals are configured in FD communication mode as follows:
- CAN frequency division coefficient 6
- CAN sync jump width 2
- CAN phase buffer segment 1 has a length of 5
- CAN The length of phase buffer segment 2 is 2
- CAN The communication rate is 1 Mbit/s
- CANFD Frequency division coefficient of arbitration segment 6
- CANFD The jump width of the arbitration segment is 2
- CANFD The length of phase buffer segment 1 is 5
- CANFD The length of phase buffer segment 2 is 2
- CANFD The communication rate in the arbitration segment is 1Mbps
- CANFD data segment frequency division coefficient 4
- CANFD Indicates the jump width of data segment synchronization 2
- CANFD The length of phase buffer segment 1 is 5
- CANFD The length of phase buffer segment 2 is 2
- CANFD The communication rate of the data segment is 1. 5Mbps
- CANFD Indicates that transmission delay compensation is enabled
- CANFD Enables the restricted mode
- The CANFD communication protocol adopts ISO11898-1
- CANFD Specifies the frequency in the arbitration phase
- CANFD Enables switchover of data segment frequency
- CANFD The communication format is FD
Filter configurations of CAN peripherals are as follows:
- Single filter mode filters extended frames
- The filter ID is 0xFA37B58
- The filter ID mask is 0xFFFFFFFF
- RTR bits are not distinguished
The communication speed of CAN peripheral is 1Mbps in the arbitration segment and 1.5Mbps in the data segment, which CAN be extended through all CAN frames
- KEY1 will randomly generate a frame of CAN communication message and send it. When the peripheral receives a frame of message, it prints the message content through USART1
- Directory contents
- CAN/CAN_FDCommunication/CAN_FDCommunication.uvprojx MDK5 project file
- CAN/CAN_FDCommunication/CAN_FDCommunication.uvoptx MDK5 project options file
- CAN/CAN_FDCommunication/JLinkSettings.ini Jlink settings file
- CAN/CAN_FDCommunication/main.c Main program
- Hardware and Software environment
- Hardware environment
- HSE crystal is 8MHz
- Pin connections are as follows:
- PA12 The pin is connected to the TX pin of the CAN transceiver
- PA11 The pin connects to the RX pin of the CAN transceiver
- PA0 Pin connected to WakeUp key (KEY1)
- PA9 Pin Connects to the RX pin of the serial port tool
- The CANL and CANH pins of two test plates A and B are respectively connected with dupont wire
- How to use it ?
In order to make the program work, you must do the following :
- Open CAN_ClassCommunication.uvprojx from this example folder by Keil MDK5
- Recompile the project and download it to two pieces of target memory
- Run the example
- Press KEY1 pin of test board A, test board B will receive a frame message and print it through the serial port. Press KEY1 pin of test board B, test board A will receive a frame message and print it through the serial port.
© COPYRIGHT 2023 Megawin Technology