Abstract: In fields such as automation control and other civilian equipment, and industrial control such as power equipment systems, many devices still use low-speed serial ports as their external communication interface. However, low-speed serial ports have inherent drawbacks: they cannot centrally, comprehensively, accurately, and in real-time monitor data. This paper introduces the hardware and software design method of an Ethernet interface based on a microprocessor-based SEP3203 serial-Ethernet converter. This method can transform traditional serial communication into network communication, enabling rapid networking of serial devices. Keywords: serial port; Ethernet port; SEP3203; Nucleus 1 Introduction In fields such as automation control and other civilian equipment, and industrial control such as power equipment systems, many devices still use low-speed serial ports as their external communication interface. Therefore, the drawback of existing systems is that they cannot centrally, comprehensively, accurately, and in real-time monitor data. With the large-scale use of Ethernet in industrial and commercial fields and the strong momentum of network automation, users and suppliers urgently need to be able to access data and perform control in real time anytime and anywhere, enabling remote rapid fault analysis and processing, and remote equipment maintenance, in order to improve quality, increase work efficiency, and reduce overall costs. Completely replacing these serial communication devices is neither economical nor feasible. For some practical needs, the serial Ethernet converter is the best solution to these problems. The serial Ethernet converter in this project is designed under this requirement. This article is a sub-project of this project. 2 Introduction to the SEP3203 microprocessor based on ARM7TDMI The ARM7TDMI processor is one of the members of the ARM7 processor series. It is a widely used 32-bit high-performance embedded RISC processor. SEP3203[1] is a 16/32-bit RISC microprocessor chip designed by the National Engineering Research Center for Dedicated Integrated Circuit Systems of Southeast University based on the ARM7TDMI processor core. It is aimed at low-cost handheld devices and other general embedded devices, providing users with rich peripherals, low power management and low-cost external memory configuration. 3 Circuit structure related to Ethernet interface in serial Ethernet converter In order to realize the research of this conversion module, a hardware platform, namely an embedded processor, must first be selected. Since ARM is a 32-bit core based on the Reduced Instruction Set Computing (RISC) system, it boasts high code efficiency, fast execution speed, and strong overall performance. Among embedded CPUs based on the ARM architecture, the SEP3203 embedded microprocessor based on the ARM7TDMI architecture offers good technical support. Therefore, this converter chooses the SEP3203 as its hardware platform. The conversion system must have a power supply for the entire system; a clock is required for system operation, thus this system needs a clock circuit. Since the user requires the converter to have serial port, USB, and Ethernet port download functions, this paper only focuses on the Ethernet port; the other two interfaces are not discussed. A network module is needed between the Ethernet port and the embedded chip. The design of the circuit structure related to the Ethernet port is shown in Figure 1. Figure 1: Relevant circuit structure of the Ethernet interface. 4. Hardware Design of the Network Interface Circuit. The SEP3203 chip does not integrate a network module internally, but it has a rich array of interfaces for easy expansion. Considering the potential for high network speed requirements, a 10M Ethernet interface was selected for this system. The network interface of this system uses the RTL8019 chip from REALTEK. The RTL8019AS is a highly integrated Ethernet chip that can easily implement plug and play and is compatible with NE2000. Because it has three levels of power-down modes, it is an ideal choice for network devices of green computers. In full-duplex mode, if it is connected to a switch or hub that is also full-duplex, it can receive and send at the same time [2]. The RTL8019AS supports 16KByte, 32KByte, and 64KByte BROMs. It also supports FLASH MENORY and page access mode, with a maximum support of 4MByte (16K×256). In addition, it also supports releasing memory after running BROM for other programs in the system to run. The system connection diagram of the network interface module is shown in Figure 2. Figure 2 Ethernet interface system connection diagram Figure 3 RJ45 network interface circuit diagram As can be seen from Figure 2, the Ethernet interface is expanded through the system bus. The address usage of RTL8019AS has three modes: 5 bits, 8 bits, and 11 bits. Using a 5-bit address, all registers of the RTL8019AS can be accessed, realizing the simplest network function. This system uses an 8-bit address to meet the operating system's requirements for the remote DMA port. The connection between the network interface module and the SEP3203 microprocessor is relatively simple, and the wiring on the PCB board is relatively regular. The actual circuit connection diagram of the network interface chip RTL8019 is shown in reference [3]. The network port uses an RJ45 network interface with built-in transformer and indicator light. The actual circuit diagram is shown in Figure 3 [4]. Compared with the SRAM interface protocol of the SEP3203 microprocessor, since the bus has no wait signal, the IOCHRDY signal is not used. Since the minimum data bit width of the SEP3203 microprocessor bus is 16 bits, the IOCS16B is fixed in 16-bit mode. 5 Software Platform Nucleus Considering all factors, we chose the embedded real-time operating system Nucleus. Nucleus PLUS is a preemptive multitasking operating system kernel designed by Accelerated Technology Inc. (ATI), a well-known American RTOS vendor, for real-time embedded applications. 95% of its code is written in ANSI C, making it very easy to port and support most types of processors. Nucleus PLUS is a set of C function libraries that can be downloaded to the target board's RAM or directly burned into the target board's ROM for execution. In a typical target environment, the Nucleus PLUS core code is generally no more than 20KB in size, making the kernel very small. In addition to providing a powerful kernel operating system, Nucleus PLUS also provides a wide variety of functional modules. These include local area and wide area network modules for communication systems, real-time Windows modules supporting graphical applications, web product modules supporting the Internet, real-time BIOS modules for industrial control computers, graphical user interfaces, and application software performance analysis modules, etc. Users can choose different application modules according to their needs. 6. Network Interface Communication Design The network interface hardware sends data transmitted from the network into system memory and notifies the operating system of the arrival of network data. Normally, the network interface uses an interrupt mechanism to accomplish this task. When an interrupt occurs, the processor suspends normal processing and jumps to the code segment of the device driver for execution. At this time, the device driver manages all the details. The device driver software notifies the protocol stack that a packet has arrived and requests corresponding processing. After the device driver software completes these tedious processing tasks, it will return from the interrupt, and the processor will continue to execute from where the interrupt occurred. In this protocol stack, the device driver shields the upper-layer application from the details of receiving and sending. Users only need to call the corresponding socket to complete the receiving and sending of data. For example, if the user wants to receive and send data in a non-blocking manner, they can use Select() and select NO_PREEMPT in the timeout parameter of Select, which allows for non-blocking receiving and sending. In this TCP/IP implementation, the protocol stack initialization is accomplished by calling NETI_Init(). NETI_Init() performs two tasks: first, it initializes the network protocol stack [5], and then it initializes the network devices used by the system. The flowchart of the network interface communication module is shown in Figure 4 [1]. Figure 4. Network Interface Communication Flowchart. Flow Description: ① The program starts with the Main() function, which calls taskmain(). ② taskmain() calls sys_ini() to initialize the system and hardware_ini() to initialize the hardware; it calls vcre_tsk() to create 6 tasks, calls stak_tsk() to put some tasks into the ready queue, and calls sys_sta() to start the system. ③ The system scheduler starts the demo_main task. ④ The demo_main() function calls ne2000_task() to start the testing process. ⑤ The main functions of `ne2000_task()` are: calling `Neti_Init()` to initialize the network device; calling `Nu_add_Route()` to add the default gateway, subnet mask, and destination IP address to the routing table; calling `Nu_socket()` to create a socket; establishing the address information data structure for the server; calling `Nu_connect()` to send a connection request to the server, and if the server returns an acknowledgment, the connection is successful; calling `Nu_send()`/`Nu_receive()` to send/receive data; after transmission is complete, calling `Nu_close_socket` to close the socket connection, and calling `Nu_sleep()` to suspend for n cycles. 7 System Testing Run the serial port debugging assistant on the PC. This software can be obtained for free online. After running the software, configure it according to the actual operating environment. Testing showed that the module forwards data normally. 8. Conclusion and Outlook Serial ports have remained popular due to their ease of use, reliability, and sufficiently high communication capabilities compared to industrial control equipment. Remote control and data sharing via serial port devices are also an inevitable trend. Therefore, the development of serial-to-Ethernet converters has practical significance and socio-economic value. The purpose of this project is to enable serial interface instruments to access the network, thus making instrument use networked. To this end, this project introduces the hardware design and software programming implementation of the Ethernet port of the converter, and designs the complete system. Because microprocessors have excellent access and control capabilities for various electrical devices, after implementing the network access function of the microprocessor, a bridge is built between the hardware devices of electrical appliances and the network. Through this, remote monitoring of various real-time signal instruments, meters, household facilities, and other targets can be achieved. On a macro level, unified management of various devices and harmonious interaction between people and systems will greatly improve work efficiency, improve the working environment, and enhance people's production and living standards. The author's innovations: ① This system uses ARM as the core processor, replacing the previous low-end CPU; the embedded real-time operating system can be ported to the system's hardware platform. ② This converter provides bidirectional conversion and transmission between RS232/RS485 ports and TCP/IP Ethernet ports, transforming traditional serial communication into network communication and enabling rapid networking of serial devices. Employing a transparent transmission method, users do not need to understand the complex TCP/IP protocol, and can even establish network connections for existing serial devices without modifying the program. References [1] Shi Longxing, Ling Ming, Wang Xuexiang, Zhong Rui. Embedded System - Application Development Based on SEP3203 Microprocessor [M]. Beijing: Electronic Industry Press, 2006. [2] Xu Jinbo. Application Research of Information Terminal Based on SEP3203 Microprocessor. [Master's Thesis]. Southeast University. 2006. [3] REALTEK SEMI-CONDUCTOR CO, LTD.. Full-Duplex Ethernet Controller RTL8019AS Publication release date: August 20, 2000 [4] http://www.prochip.com.cn/manage/file/GD01DataSheet .pdf [5] Lü Changtai, Luo Yonggang. Research and Design of Embedded Ethernet Interface. Microcomputer Information [J]. 2006 (8-2): 68-70.