****************** (C) COPYRIGHT 2023 Megawin Technology *******************
* @file CAN/CAN_ClassCommunication/readme.txt
* @author Megawin Application Team
* @version V0.0.4
* @date 16-June-2023
* @brief Description of the CAN class communicaion 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 how to use the controller Local Area Network (CAN) Class standard for communication and how to set the CAN filter.
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.
The CAN peripheral is configured in Class communication mode.
- Frequency division coefficient 6
- Sync jump width 2
- The length of phase buffer segment 1 is 5
- The length of phase buffer segment 2 is 2
- The communication rate is 1Mbps
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 peripherals is 1Mbps, which CAN be extended through all the 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_ClassCommunication/CAN_ClassCommunication.uvprojx MDK5 project file
- CAN/CAN_ClassCommunication/CAN_ClassCommunication.uvoptx MDK5 project options file
- CAN/CAN_ClassCommunication/JLinkSettings.ini Jlink settings file
- CAN/CAN_ClassCommunication/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