RBwJYm96um

【CW32】Communication Experiment Board

 
Overview

# **Multi-machine communication based on cw32**
##
Design a communication system for multi-machine interconnection in a complex communication environment.

This system uses CW32F030C8T6 as the main control chip .

The small board independently leads to IIC and SPI. In addition, a CH340 module for USB to serial port and an RS485 communication module are connected.

A good-looking minimum system board
## Overall circuit design

This small board is mainly used for the verification design of the communication method, so all the pins are brought out. For several commonly used communication function pins, the interfaces of the pins are arranged separately around the board in the usual order

## For oled,
the IIC interface on the top of the board can be used for communication testing, and the interface of the OLED screen can also be used. There are 8 interfaces in total, and the order is arranged according to the small screens sold by the merchant
(4 interfaces and 8 interfaces)
![image.png]
**It should be noted that when using eight interfaces, the control line on the back of the board needs to be soldered**. When using 4 lines, the other ports can be used as normal port outputs
![image.png]
## For RS485
, this design uses the MAX1348 communication chip. This chip has two versions for E The version can achieve error-free communication of 500kb/s, and using this differential communication method, only two wires are needed to send and receive messages when multiple machines are connected. More about RS485 ([The store manager's little watermelon: RS485 communication](https://oshwhub.com/article/RS485tong-xin-zi-dong-shou-fa-dian-lu))
**Also for this interface, the connection can be left unwelded when not in use** t1 and t2
For the welding of this interface, the temperature of 200 is most suitable
![image.png] ## The communication scheme
is based on the idea of ​​modbus, and divides a section of information into the start, address area, instruction area, data area, check area, and stop character
![image.png]
This section of information indicates: the start character is @, the address is 001, the instruction is 110, the data bits to be received are 65533, the crc check code is 3CFC, and it comes with a carriage return character but it is hidden. In this section of data, I added a # for each area Used to distinguish, in actual application, remove the # judgment and change it to data bit judgment to achieve the same
! [Screenshot 2023-04-10 212938.jpg]
## Code Implementation
### Data Processing
When using the serial port to send text data, the decimal number of the ascll encoding table is sent, and it will be stored as a hexadecimal number after entering the microcontroller. We need to make different storage types when extracting data according to the purpose of the data in each area. For example, when extracting the number, storing the number as a character type can provide us with more abundant number selections: A001;
![image.png]
### crc check
This is a calculator for crc check for verification: [crc check computer](http://www.ip33.com/crc.html)
This is a crc model referenced by some communication protocols, where:
WIDTH: width, that is, the generated CRC data bit width (0000/0000 0000/0000 0...)
POLY: Hexadecimal polynomial (you can see that there is a corresponding polynomial in each model; such as the modbus model, the 16th, 15th, 2nd and 1st bits of the data are '1', and then converted to hexadecimal). Note that the highest bit is omitted
![image.png] INIT: CRC initial value, consistent with the WIDTH bit width
XOROUT: The calculation result is XORed with this parameter to obtain the final CRC value
REFIN: true or false, whether the original data is flipped before calculation (note that the flip is bit-by-bit, such as: 0011 == 1100)
REFOUT: true or false, after the operation is completed, whether the CRC value is flipped (same as above)
![image.png] ##### CW32f030 comes with crc check and corresponding model, so we don't need to write a specific check, just learn to call it, and the hardware's built-in crc check runs faster than the software implementation. For calling method, refer to [cw32 official program transplantation reference](https://oshwhub.com/article/CW32-UART)

### **Debug**
![image.png] Click here to enter debug mode
![image.png] You can add a variable observation window here
![image.png] Copy the variable into the serial port, and you can see the result of the crc check in real time

##### Serial port default configuration
![image.png] It should be noted that in the code I wrote, the data stop bit is a line break, that is, you need to press the enter key once after the last

##### I transplanted an RTOS in cw32. It can be deleted directly if it is not used. It is only used in the main.c function. The transplantation process is: [cw32 RTOS transplantation](https://blog.csdn.net/qq_48997726/article/details/129696316?spm=1001.2014.3001.5501)

#### There are two corners of space above the PCB board to place the communication module you need
![image.png]
#### Schematic diagram of the welding point buttons on the back
![image.png]
##### 4.14 Verify the communication between different power supplies
![IMG_20230414_212748.jpg]
##### 4.15 Send preemption
map
![image.png] Code implementation
![image.png] ## More functions are still being improved
###### **It is expected to improve the send preemption collision detection**
参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-06-19 09:29:57

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号