Communication Programming Based on HMS30C7202 Embedded System
2026-04-06 03:01:44··#1
Abstract: Embedded systems have gained widespread application due to their small size, high performance, low power consumption, high reliability, and industry-oriented characteristics. This paper studies the design and development technology of embedded board network communication program based on TCP/IP protocol, using the HMS30C7202 embedded system with ARM720T core and Red Hat 9.0 operating system. A program was designed and implemented to provide network communication services between the PC and the board. Keywords: HMS30C7202; TCP/IP; Embedded system; Communication Introduction Embedded systems represent a new technological development direction following IT network technology. Due to their small size, high performance, low power consumption, high reliability, and industry-oriented characteristics, embedded systems are now widely used in various fields such as military defense, consumer electronics, network communication, and industrial control. With the development of computer and communication technologies, the research and development of embedded systems has increasingly important practical significance. The current widespread adoption of the Internet has placed higher demands on the network functions and performance of embedded devices. The speed and memory limitations of 8/16-bit microcontrollers make it difficult to meet the network requirements of embedded devices, thus 32-bit RISC processors are increasingly favored. Since its founding in 1990, ARM has made continuous breakthroughs in 32-bit CPU development, achieving a leading position in the industry. Coupled with the significant advantages of its core designs, such as low power consumption and low cost, it has gained strong support from numerous semiconductor manufacturers and system integrators, achieving great success in the 32-bit embedded application field. Network service communication devices in embedded systems, as an important component of embedded systems, have strong practicality and research value, providing an excellent means for remote control and intra-network information transmission. This paper, based on the HMS30C7202 embedded system with the ARM720T core and the Red Hat 9.0 operating system, studies the design and development technology of embedded board network communication programs based on the TCP/IP protocol, realizing communication between boards and laying a solid foundation for future network service applications in practical environments. 1. HMS30C7202 Development Board Introduction The HMS30C7202 is a 32-bit highly integrated, low-power microprocessor, composed of an ARM720T core and other peripheral interface devices. It supports 8K of data and instruction cache, segmented and paged memory MMU, write buffer, and AMBA interface. The HMS30C7202 uses a 0.25mm low-power CMOS process, with an on-chip voltage of 2.5V and I/O support of 3.3V. It is packaged in a 256-pin QFP/BGA package. The HMS30C7202 has abundant on-chip resources and extremely high integration, making it ideal for embedded system applications. It is mainly used in PDAs, smartphones, and personal audio devices. The HMS30C7202 chip supports the following internal and external devices: multi-channel DMA (Direct Memory Access), three timers and one watchdog timer, intelligent interrupt controller, memory controller (such as ROM, Flash, SRAM, SDRAM), power management unit, LCD controller, timing clock (32.768kHz crystal oscillator), infrared communication interface (SIR supported), four serial ports (compatible with 16C550), PS/2 external keyboard/mouse interface, two-channel PWM interface, matrix keyboard control interface (8*8), general I/O ports, MMC/SMC card interface, two CAN interfaces, USB interface, on-chip ADC interface module (can be used for battery detection, audio input, touch screen), on-chip DAC interface module (8-bit stereo audio output), three PLL clock JTAG debugging interfaces, etc. Network transmission is one of the most important data transmission methods today. Since the HMS30C7202 itself does not have an Ethernet control module, a matching control chip is needed, such as the CS8900. The CS8900 is a single-chip full-duplex Ethernet controller. Combined with necessary digital and analog circuits, it forms a complete Ethernet circuit. Its main structure includes an ISA bus interface, 802.3 MAC, buffer, serial EEPROM interface, and an analog front-end with 10BABE-T and AUI. The HMS30C7202 achieves network link layer connections by operating the CS8900's control registers and reading/writing the CS8900's internal data registers. [Diagram 2 shows the connection between the CS8900 and the development board.] Introduction to TCP/IP Protocol: The TCP/IP protocol is a set of protocols including TCP (Transfer Control Protocol), IP (Internet Protocol), UDP (User Datagram Protocol), ICMP (Internet Control Message Protocol), and others. Most client-server applications use TCP or UDP. TCP (Transmission Control Protocol) is connection-based, meaning two computers must establish a connection before data can be transmitted. In fact, the sending and receiving computers must constantly communicate with each other. UDP (User Datagram Protocol) is a connectionless service; data can be sent directly without establishing a network connection between the two computers. Compared to connection-oriented TCP, it consumes less bandwidth, but you don't know if your data has actually reached your client, and the client doesn't know if the received data is in the correct order. In this program's writing and debugging, we used the TCP protocol. 3. Program Design This program design is a crucial foundation for the networking of vending machines and is part of the campus network construction. Currently, most vending machines in universities use a coin-operated payment model. A coin recognition system is a crucial hardware device for implementing this model; however, this device is costly and has poor stability, hindering the widespread adoption of vending machines. By embedding an ARM processor into a vending machine and implementing network connectivity for the embedded system, card-swiping payment can be achieved, and the machine's status information can be remotely queried, allowing managers to monitor the machine's status promptly. Therefore, the design and implementation of this program has strong practical significance. This program design is based on a client-server model (as shown in the diagram). A socket is established on the server, bound, and then the `listen()` function listens on the bound port. The `accept()` function is used to prepare to receive or send information. The client also establishes a socket, but does not bind a port; it directly establishes a connection with the server using the `connect()` function, and then sends or receives data. This article describes the specific program using an ARM board as both the server and client. TCP communication is implemented in two modes: ARM board as server, PC as client; ARM board as client, PC as server. Communication is achieved via Ethernet connection. Mode 1: ARM board as server, PC as client. The specific program is written according to the process as follows: #define MYPORT 3490 // The port that the server listens on #define BACKLOG 10 // The number of connections that can be accepted at the same time int sockfd, newfd; // Listen on sockfd and accept new connections with newfd struct sockaddr_in my_addr; // Store its own address information struct sockaddr_in their_addr; // Store the address information of the connection if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { perror("socket"); exit(1); } // Establish a socket, check if there is an error, and return the error information if there is an error my_addr.sin_family = AF_INET; // Host byte order my_addr.sin_port = htons(MYPORT); // Network byte order my_addr.sin_addr.s_addr = INADDR_ANY; // Automatically fill the local IP address with bzero(&(my_addr.sin_zero), 8); // Clear the rest of the structure if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1) { perror("bind"); exit(1); } // Bind the local IP address and port if (listen(sockfd, BACKLOG) == -1) { perror("listen"); exit(1); } // Listen on the port while(1) { sin_size = sizeof(struct sockaddr_in); if ((new_fd = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size)) == -1) { perror("accept"); continue; } // Returns a new socket descriptor, which is the connection to the remote computer. The first socket descriptor is still on the same port as the original one. listen() if (!fork()) // Establishes a child process to handle the connection if (numbytes = (recv(new_fd, buf, maxdatasize, 0)) == -1) { perror("recv"); exit(1); } // Receives information sent by the client into the buffer close(newfd); // Closes the socket program to listen on port 3490 on the ARM board, ready to receive information from the remote computer with the established connection. printf("Received: %s", buf); can display the information sent by the remote computer in the buffer. Mode 2: ARM board as client, PC as server. The program is written according to the process as follows: #define PORT 3490 // Define remote port information #define DEST_IP "210.43.8.21" // Define remote computer IP information struct sockaddr_in their_addr; // Define a structure to store the remote computer address if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { perror("socket"); exit(1); } // Establish a socket if (connect(sockfd, (struct sockaddr *)&their_addr,sizeof(struct sockaddr)) == -1) { perror("connect"); exit(1); } // Connect to the remote computer if ((send(sockfd, "hello,my world!\n", MAXDATASIZE, 0)) == -1) { perror("send"); exit(1); } // Send data to the server close(sockfd); // Close the socket after sending. This program implements the connection from the ARM board to a remote computer through port 3490, and sends data after a successful connection. This program realizes information communication between boards, laying a solid foundation for communication between vending machines and servers. It provides a feasible means for the networking of vending machines. 4. Summary The TCP/IP protocol has become the most important Ethernet protocol, and TCP communication has become the main method of wired communication in embedded systems. The ARM board can act as both a client and a server. This communication method is widely used and has high research value. The innovation of this paper lies in the research on the design and development technology of embedded board network communication program based on TCP/IP protocol, and the method of writing board communication program based on TCP protocol is given, realizing communication between PC and ARM board. This lays a solid foundation for future applications and communication program development of network-based embedded systems.