Design and Application of an embedded SMI network Converter Based on ARM and uC/OS

Source: Internet
Author: User
ArticleDirectory
    • Design and Application of an embedded SMI network Converter Based on ARM and uC/OS
Design and Application of an embedded SMI network Converter Based on ARM and uC/OS

Embedded online favorites | print

Introduction

At present, with the development of the Internet and embedded systems, more and more industrial measurement and control devices have used the network access function as their default configuration to achieve remote monitoring of devices and distributed processing of information. However, a large number of industrial field devices do not yet have network interfaces. In the development of ip113f Optical Fiber transceiver monitoring system, the lower computer communicates with the SMI of the optical fiber transceiver through the microcontroller to achieve monitoring, and the lower computer transmits data through the RS-232 interface. The distance between the serial port and the local port is short. Every day, the staff will go to the site to check and diagnose the data. In this case, it is necessary to design a data transmission module from SMI to the Internet to remotely monitor the running status of the optical transceiver.

Introduction to ip113f chips

The ip113f chip is an optical transceiver with network management and ultra-low power consumption. It supports 3.3 v I/O and operates two sets of independent registers through SMI (MDC, mdio, to monitor or reset the working status of local or remote Optical Fiber transceiver. You can access registers through the serial management interface, as shown in figure 1. Because the IP address of ip113f is a 5-bit binary code, a management unit can plug in up to 32 (25) ip113f at the same time. Data is transmitted in one position on mdio and is on the rising edge of MDC. The data communication protocol on mdio is shown in table 1. When SMI is idle, mdio is in high-impedance state. The management unit sends 32-bit continuous "1" and "01" signals on mdio to initialize the mdio interface.

Overall Function Design

The basic function of the system is to communicate with a remote pc through the same SMI network converter at the same time with 32 Optical Fiber transceiver, as shown in figure 2. The rest of the work done by the converter is to receive the test data sent from the local or remote Optical Fiber transceiver, automatically identify its length and source, convert it into the network data format, and send it to the upper computer through Ethernet, at the same time, the host computer receives control information sent over Ethernet, automatically identifies the Sending target, and then sends it to the corresponding Optical Fiber transceiver through the SMI port. You can configure the IP address of the SMI network converter over Ethernet in the host computer as needed.

Hardware Structure Design

The hardware circuit of the converter selects the embedded processor lpc2214 Chip Based on the ARM7 kernel for overall control. The lpc2214 chip has a kb high-speed flash and 16 K in-chip SRAM. In order to meet the data caching and system running space requirements during communication, the off-chip extended KB of SRAM using is61lv25616al. In addition, the 256-byte EEPROM is extended out of the chip through the IIC bus to save the configured IP address. The 10 m full-duplex Ethernet controller RTL8019AS chip is used for network communication. The hr61101 chip acts as the NIC transformer. The universal I/O port, serial 5 and serial 6 are used to simulate the communication sequence of Sim, and ip113f is collected. The overall hardware circuit 3 shows.

Lpc2214 has an external memory interface and can expand the memory groups of four banks (bank0 ~ Bank3), and bank0 ~ Bank3 chip selection signal are CS0-CS3, this design, with bank0 extended SRAM, bank3 extended RTL8019AS module. Because the lpc2210 chip is a 8/16/32-bit microprocessor, it can accept 16-Bit Data bit-width read/write. The design connects the 16-bit I/O port iocs16b OF THE RTL8019AS chip to a high level to implement the read/write control register in the 16-bit operation mode, improve system operation efficiency. The 65-foot JP of RTL8019AS is connected to the High Level to select the jumper mode, that is, the I/O and interruption of RTL8019AS are determined by the jumper, you do not need to expand the storage information of the eeprom 93c46 chip to control the I/O and interruption of the RTL8019AS, reducing connections and improving the stability of high-frequency circuits. When RTL8019AS works in jumper mode, its base address is 0x300. Because the RTL8019AS operating power supply is 5 V, and the I/O voltage of the lpc2210 is 3.3 V, the protection resistance of 470 Ω is connected in series on the bus connection.

System Software Design and Implementation

Introduce RTOS

Data collection of Optical Fiber transceiver requires high real-time performance. If the traditional front-end and back-end design method is used, the data collection is too complex and the real-time performance cannot be guaranteed. The real-time operating system RTOS can solve this problem. μC/OS-II operating system isSource code1-litre RTOS,CodeIt is short, concise, and easy to learn. It is an ideal choice for this design.

TCP/IP protocol selection and reduction

To enable the Ethernet access function of the SMI converter, TCP/IP protocol must be embedded in the ARM processor. Based on the Open Systems Interconnection (OSI) model, the TCP/IP protocol embedded in arm uses a simplified layer-4 model, namely, the link layer, network layer, transmission layer, and application layer. Based on actual needs, combined with the processing capabilities of ARM microprocessor, the complete TCP/IP protocol is fully reduced in the design. The link layer is composed of underlying protocols that control data transmission between different machines on the same physical network. It is driven by RTL8019AS.ProgramIt is implemented at this layer. At the network layer, ARP packets only respond to ARP requests, cancel RARP, maintain only the simplest ing cache table between IP addresses and MAC addresses, and regularly refresh; for the transmission layer, considering the designed system data transmission security, the TCP protocol is selected in the design. For the application layer, the HTTP protocol is cropped and the control interface is set on the upper computer to replace its function.

Through the preceding cropping, a suitable TCP/IP protocol is obtained. The cut TCP/IP protocol is embedded into the operating system μC/OS-II, and provides the API function supply program call, so that arm can quickly send and receive TCP packets without conflict, meets the real-time and reliability requirements of industrial measurement and control systems.

Key Issues

When two-way communication is performed between the SMI serial port and Ethernet, if the data transmission rate of both parties is in the synchronous state, that is, the receiver speed is equal to the sender rate, the system can immediately forward the data. However, in most cases, the data transmission rate between the sending and receiving sides is inconsistent. Compared with Ethernet, the serial port is a slow connection, which may lead to data loss. Therefore, a circular queue must be defined in the system as a buffer for sending and receiving data. In this system, two 1024-byte cyclic queues are defined as the data sending and receiving buffer, one is the serial port receiving buffer, and the other is the Ethernet receiving buffer. Ethernet transmission is triggered by interruption. In contrast, the serial port and Ethernet transmission tasks have a low priority. the received data cannot be forwarded immediately, but is saved in the cyclic buffer zone. 4. head and tail point to the header and tail of the queue respectively. When head = tail, the queue is empty. (Head + 1) mod 1024 = tail indicates that the queue is full, the size of the idle buffer can also be calculated using the head and tail pointers.

In the serial communication protocol of the transceiver, local/remote terminals and transceiver numbers are added to identify the source address and destination address, and data is verified. Since the IP address of the converter is mainly set through the upper computer over Ethernet, the command header is added to the Ethernet data frame to identify whether the IP data is set or the data that communicates with the transceiver.

Implementation of Software Systems

The entire software design of the system consists of the operating system and a series of user applications. The system creates a startup task taskstart (), which initializes the system hardware, including clock initialization and startup, interrupt startup, and RTL8019AS initialization and startup, various Application tasks are divided. Based on the importance and timeliness of each task, the entire module is divided into six application tasks with different priorities, that is, IP Address Setting, receiving protocol conversion, sending protocol conversion, net sending, SMI sending, and SMI collection.

Task execution

After a task is divided, each task has an independent stack space, competing for CPU usage. Once the CPU usage is obtained, it runs independently to complete specific functions.

The system uses arm as the server and PC as the client's TCP communication mode, and the upper computer actively requests to connect to arm. Before establishing communication between the serial port and Ethernet, call the IP Address Setting task to initialize the communication parameters of the IP address, subnet mask, gateway, and SMI port.

The functions of SMI port communication include sending SMI and collecting SMI. The SMI collection task has a low priority. If no related event occurs after multi-task scheduling, the system will continue to run the SMI collection task. If the status of the collected local or remote ip113f changes, after the data is converted through the Protocol, it is sent to the remote host computer. SMI is sent to run independently as a separate task. The SMI sending task requires the system scheduler to notify the buffer of the data to be sent. If no data is sent, the task is suspended and the system runs other tasks, as shown in Figure 5.

The Ethernet communication module consists of Ethernet data transmission and receiving and protocol conversion. Data is received in the interrupt service program of RTL8019. The Ethernet data transmission, receiving protocol conversion, and sending protocol conversion are independent tasks. The task of sending Ethernet data also requires the system scheduler to notify the buffer zone of the data to be sent. Protocol conversion is mainly used to parse received data packets and add protocol headers to the data to be sent. During programming, you can directly call the API functions embedded in the TCP/IP protocol to layer data packets.

Synchronization and scheduling between tasks

Generally, a task in a multitasking operating system is an infinite loop with no return value. If a task without a higher priority enters the ready state, the current task will not give up its CPU usage right. In order to achieve normal operation of the operating system and synchronization of related events, the communication and event flag settings between tasks must be correctly handled. The functional structure of the system is shown in Figure 6.

After the system executes multi-task scheduling, a high-priority task is blocked due to a resource application and enters the suspended state. The system runs a SMI collection task with a lower priority. Each event is assigned a semaphore. Once an event occurs, the task enters the ready state. When the receiving interruption occurs, start the protocol conversion task. This process is implemented through the semaphore communication mechanism. The receiving protocol conversion task first parses the data from the host computer, then sends the data to the SMI sending queue or the eeprom sending Queue according to the Data command hair, and then starts the corresponding SMI sending task or ipsetting task. After the sending protocol conversion task converts the data collected by SMI, it stores the data in the Ethernet sending queue, notifies net to send the task, and sends the data to the host computer to ensure synchronization between the task and the event.

Conclusion

The SMI network converter designed in this article implements the host computer's ability to monitor both local and remote 32 Optical Fiber transceiver. The design uses the lpc2214 chip to overcome the resource shortage and limited processing capability problems caused by the original 8-bit single chip microcomputer processor. In the software, the cut-off TCP/IP protocol is adopted, which greatly simplifies programming complexity. embedding the μC/OS Operating System greatly improves the real-time performance of the system. The system runs well and works stably. The software can be used on other serial devices with slight changes, which has broad application prospects.

Source: Electronic Design Application Author: Liu yipeng, embedded R & D center, school of physics and Information Engineering, Fuzhou University

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.