Design of multi-serial communication based on embedded WinCE and MSP430 single-chip microcomputer

Publisher:星光闪耀Latest update time:2011-08-25 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Abstract: In remote monitoring and industrial automation systems, serial communication has been widely used because of its advantages of simple connection, easy use and high reliability. This paper discusses the problem of using WinCE embedded and MSP430 single-chip microcomputer to build a serial multi-machine communication system. Based on the analysis of the characteristics of WinCE operating system and MSP430 single-chip microcomputer serial port module, the overall block diagram of serial communication is given. According to the problems existing in actual serial communication, a serial communication protocol is formulated. Then, based on the hardware of the system, the WinCE system kernel is customized according to the needs, and finally the serial communication design is realized. The experimental results show that the system can meet the requirements of multi-serial communication.
Keywords: WinCE; MSP430; TCP/IP; Serial communication protocol

At present, WinCE embedded and MSP430 single-chip microcomputer are widely used in instrumentation, industrial control, mobile devices, etc. In many complex applications such as multi-point temperature acquisition and multi-point speed acquisition, one single-chip microcomputer cannot meet the requirements, and multiple single-chip microcomputers need to work together. At this time, the communication of multiple single-chip microcomputers is the key to realization. Based on WinCE embedded devices as the core, replacing the traditional PC, the serial communication system built with TCP/IP communication mechanism combines the advantages of embedded devices and network technology to unify the complex communication protocols and data formats of each independent system. It is particularly suitable for remote and multi-machine serial communication and has important use value and application prospects.

1 Hardware Platform
1) WinCE embedded uses the mini2440 development board of Friendly Arm as the hardware platform. The main hardware resources of the mini2440 development board include: Samsung S3C2440A, main frequency 400MHz, maximum 533 MHz; 1 100M Ethernet RJ-45 interface (using DM9000 network chip), 1 universal asynchronous serial port (UART); 2 USB data interfaces; 1 LCD controller; 1 64MSDRA-M; 1 SD card interface; as well as keyboard interface and IDE interface, etc. Using the above core hardware resources, customize the relevant kernel according to needs, and write applications in the EVC integrated development environment.
2) MSP430F149 microcontroller is a chip from TI. It has the advantages of high integration, rich peripherals, ultra-low power consumption, low voltage supply range of 1.8-3.6 V, 5 optional low power modes, wake-up time of less than 6μs, etc. It is an excellent choice for designing battery-powered systems. With 16-bit RISC structure, 16-bit registers and constant registers, MSP430 achieves maximum code efficiency. The digitally controlled oscillator provides the ability to quickly wake up from all low-power modes to active modes in less than 6ms. MSP430F149 has 2 16-bit timers (with watchdog function), extremely fast 8-channel 12-bit A/D converter (ADC) (with internal reference voltage, sample and hold and automatic scanning functions), 1 internal comparator and 2 universal synchronous/asynchronous transmitters and receivers. The hardware multiplier improves the performance of the microcontroller and makes the microcontroller compatible in coding and hardware, so it has been widely used in many fields. 3) PC and WinCE embedded are connected through 100 M/S Ethernet interface, WinCE embedded communicates with MSP430F149 through RS232, and the overall block diagram of serial communication is shown in Figure 1.

a.jpg



2 WinCE Embedded Platform Customization
WinCE embedded operating system is a compact, efficient, scalable, open, customizable, 32-bit real-time embedded window operating system. Its biggest feature is the use of layered structure technology, which makes the system more scalable and customizable, making the application and operating system independent of specific hardware to adapt to various special application environments. The operating system can be logically divided into hardware layer, OEM layer, operating system layer, and application layer. Customization based on the embedded WinCE development platform mainly customizes the operating system layer and OEM layer.

Microsoft provides PB (Platform Builder) as an integrated development environment for customizing the WinCE operating system. The PB environment supports a variety of functional modules and hardware interfaces, and can tailor and customize WinCE according to the specific hardware configuration of the target device. The process of customizing the WinCE platform is shown in Figure 2. First, customize the hardware such as the network card, serial port, display driver, USB and power driver by installing and creating device drivers; then customize system components and services, including TCP/IP, FTP, MFC, Telnet, etc., and modify the configuration file according to the hardware configuration and the application characteristics of the operating system; finally, generate the operating system image file and download it to the target device through the network port or serial port for operation. After the customization is completed, export the application development kit SDK.

b.jpg



3 Serial UART Module
3.1 WinCE Operating System Serial Port
Programs running under WinCE are generally developed in Windows environment and then downloaded to embedded devices. In the system, EVC is used to develop application software under Windows environment and then downloaded to the device. Serial port in WinCE is a stream interface device, which can be opened, closed, read and written like a file. The serial port function under WinCE is basically the same as that under Windows, but there are some differences: 1) WinCE only supports Unicode; 2) WinCE has some unique controls that can facilitate programming; 3) EVC does not support overlapping I/O operations. 3.2
Developing serial communication under WinCE Steps
1) Open the port and initialize it In EVC, the device is treated as a file, so CreateFile is used to open the port. If the opening is successful, the handle of the open serial port will be returned. After successfully opening a port, the port needs to be initialized. Call the serial communication function SetupComm to set the size of the COM send and receive buffers. After allocating the buffer, call the CetCommTimeouts function to set the timeout for reading and writing the serial port. Then call the GetCommState function to obtain the default parameters of the current serial port and return a DCB structure address. Reset the serial port status by assigning values ​​to each member of the DCB structure. Finally, call the PurgeComm function to clear the serial port's send and receive buffer.
2) Read and write operations on the serial port After successfully configuring the serial port parameters, you can call the ReadFile and WriteFile functions to read and write the serial port. During the communication process, communication errors may occur, causing the program to be unable to continue. Generally, you need to call ClearCommError to clear these errors.
3) Close the serial port The serial port must be closed after use. The serial port cannot be shared like a file, and other applications cannot use it without releasing it. To close the serial port, just use CloseHandle. The WinCE serial port flow chart is shown in Figure 3.

c.jpg


3.3 Features of UART module of MSP430F149 MCU The UART module of MSP430 MCU has more complete features than ordinary 51 MCU, such as selectable parity check mode, programmable baud rate fraction, error control and error status bit, serial port interrupt to wake up CPU, etc. Applying these features to serial port communication can enhance the reliability of communication, for example: UART hardware module can be set to not receive current data if parity check is wrong, baud rate can be made more accurate by setting baud rate modulation value, and the application of sleep mode can improve CPU working efficiency and reduce system power consumption. For multi-machine communication, MSP-430 MCU has built-in idle-line and address-bit multi-machine communication modes, which provide a guarantee for reliable and efficient multi-machine communication. The two modes mainly differ in how to determine the address frame: 1) Idle mode: the transmission idle time between two data blocks is greater than or equal to 10 bits, that is, the first data after the transmission line is greater than or equal to 10 bits of idle time is used to represent the address. 2) Address bit mode: The address bit (1 or 0) in the byte frame indicates whether the frame is an address frame or a data frame. 1. Since the idle mode requires that there must be a time interval greater than or equal to 10 bits between two data blocks, the transmission rate will be slower than the address bit mode in the case of continuous transmission, but the programming is simple. 4 Serial communication protocol design In the communication between WinCE embedded and multiple MSP430 microcontrollers, it is key to determine a clear and reasonable communication protocol, including unified regulations on data format, communication method, transmission speed, transmission steps, error detection and correction methods, and control character definitions. In order to distinguish different extensions, a unique address must be assigned to each extension, which uniquely distinguishes each microcontroller. The data format is in the form of a data packet, transmitting a group of data at a time. The data packet format is shown in Table 1.



d.jpg


The address bit in the data format indicates the address of the microcontroller communicating with the PC. The operation command indicates the operation to be completed in this communication. When the microcontroller sends and the host computer receives, the data length, data content, and checksum fields in the data packet are filled with the number of data actually sent, data, and checksum; the operation command field also has similar protocol regulations when the PC sends and the microcontroller receives.

5 TCP/IP data communication
The TCP/IP data communication module is used to complete the communication between WinCE embedded and PC server. Its main functions include receiving information sent by the lower computer, sending control commands, controlling the running status of the program, and providing convenience for multi-machine serial port communication. The data communication module adopts the TCP/IP protocol based on WinCE, which can ensure the accuracy and reliability of data during transmission; the embedded system hardware has strong anti-interference ability, which can ensure the long-term stable operation of the system. The program flow of the client process to establish a connection and communication is shown in Figure 4.

e.jpg


In the TCP/IP protocol based on Wince, the communication implementation process is as follows: the TCP server first calls the socket() function to establish a streaming socket, then calls bind() to bind the local address, and calls the listen() function to connect to the client terminal. Once connected to the client terminal, the server calls the accept() function to receive the terminal's connection request and establish a connection. At the same time, the server starts a new thread to establish a separate socket instance to communicate with the client terminal.
The TCP client communication implementation process is as follows: call the socket() function to establish a streaming socket, then call the connect() function to request to establish a TCP connection with the WinCE server. After the connection is successfully established, data is transmitted with the server.
The service process and the client process exchange data by calling send() and recv(), and the server can send the collected data to the client. The client feeds back control information and parameter adjustment information to the server: the service process or the client process can cancel the socket and interrupt the connection by calling close().

6 Conclusion
Serial communication is widely used in computer control systems. Through the research and development of serial communication between WinCE embedded and multiple MSP430 microcontrollers, multi-machine serial communication is realized by using embedded, microcontroller and network communication technology. The communication protocol designed in this paper has been proven to be stable and reliable in practice, ensuring the accuracy of data transmission between the microcontroller and the PC. The technology used in this paper has important practical value and broad application prospects in the fields of remote control and industrial control.

Reference address:Design of multi-serial communication based on embedded WinCE and MSP430 single-chip microcomputer

Previous article:Design of water gate voice alarm system based on AT89S52 and ISD1760
Next article:Implementation of wireless temperature monitoring system based on single chip microcomputer

Latest Industrial Control Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

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号