A reliable and low-cost embedded Ethernet interface design

Publisher:心灵律动Latest update time:2014-11-13 Source: 21icKeywords:CP2200 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Introduction 

       At present, when embedded designers provide Ethernet access for remote control or monitoring equipment, the Ethernet controllers they use are designed for personal computer systems, such as RTL8019, DM9008, CS8900A, etc. These devices are not only complex in interface circuits and large in size, but also relatively expensive. CP2200 is an independent Ethernet controller recently launched by Silabs . It complies with the IEEE 802.3 protocol, supports 10M Ethernet access, and only requires a few external circuit connections to meet the design requirements of most embedded Ethernet interfaces, which greatly simplifies the design of embedded Ethernet interfaces, greatly reduces the board space, and greatly reduces the system development cost. In
       addition, the Ethernet controller has an 8-bit parallel host interface, which can provide Ethernet communication functions for most microcontrollers or main processors. The 8-bit parallel bus interface supports Intel and Motorola bus modes and can be addressed in multiplexed or non-multiplexed modes. These functions, together with the TCP/IP protocol stack of the relevant processor, make the Ethernet interface implementation of embedded application systems extremely simple.

Hardware Circuit Design

The hardware circuit of the system is shown in Figure 1. The peripheral circuit of CP2200 is relatively simple.

Figure 1 Hardware circuit

I/O parallel interface

       The parallel host interface of CP2200 supports two bus modes, Motorola and Intel, and supports address data multiplexing and non-multiplexing. The host interface bus mode can be configured by grounding the MUXEN and MOTEN pins or pulling the level high.

Ethernet transformer

       To implement the Ethernet interface, the Ethernet transformer is indispensable. On the differential receiving pin (RX+/RX-), a 1:1 pulse transformer dedicated to 10BASE-T operation is required. On the differential transmitting pin (TX+/TX-), an external 1:2.5 pulse transformer with a center tap is required. The transformer should have a voltage isolation performance of more than 2kV to prevent electrostatic interference. The transmitting end requires two 8W (accuracy of 1%) resistors and a 560pF capacitor connected to the specific end, and the receiving end requires a 100W resistor connected to the specific end.

       According to the requirements of CP2200, the author uses the PRJ series PRJ-010 type transformer. The transformer integrates an RJ-45 connector, which saves a lot of wiring and improves the reliability of high-frequency signal transmission.

Other circuits

       LINK and ACT pins output levels to drive LEDs to indicate network connection and activity status.

       All power pins must be connected to the same external 3.3V power supply. Similarly, all reference grounds should be connected to the same ground point externally. Each VDD and VSS pin should be connected to a 0.1mF ceramic bypass capacitor as close to the pin as possible.

       It should be noted that driving the twisted pair interface requires relatively high current, so the Ethernet transceiver data line should be as short as possible, and the wire diameter should be appropriately increased to reduce resistance loss (in order to ensure reliable data transmission, the author's PCB circuit board selected a 20mil wire diameter).

Software Design

       TCP/IP protocols are of various types and their interactions are complex. It is impossible to implement all protocols on a single-chip microcomputer, so the protocol stack must be tailored. Combined with the specific communication requirements of the system, the author's system finally retained only TCP, UDP, IP, ICMP, and ARP protocol modules. In the overall design of the protocol stack program, considering that the single-task execution mode of the single-chip microcomputer is difficult to give full play to the characteristics of the TCP/IP protocol, we adopted the implementation method of the TCP/IP protocol stack based on the event-driven mechanism. The introduction of this mechanism ensures that the system has high efficiency in assembly language code while greatly improving real-time responsiveness. The following will specifically explain the characteristics of the event-driven mechanism and the implementation of the TCP/IP protocol stack based on this mechanism. After the

event-driven mechanism

       system is initialized, it enters the event loop body and continuously queries whether there are events in the event queue of C8051F040. Once the event queue is not empty, the event flag word is read to determine the event type, and then the corresponding event processing subroutine is called. After the processing subroutine is executed, it still returns to the event loop body. The event flag word is driven directly or indirectly by the interrupt. When an event occurs, it only needs to set the corresponding bit of the status word in the interrupt service program. The interrupt continuously adds events to the event queue, and the C8051F040 handler continuously reads the event flag word from the event queue to process the event.

The characteristics of the event-driven mechanism are:

* In the interrupt processing program, only simple program statements such as changing the event flag word are executed, and the event is added to the event queue of C8051F040 and then returned immediately. Therefore, the system closes the interrupt for a very short time. The real-time performance of the system's interrupt processing is enhanced.

* C8051F040 performs corresponding event processing or adds events required for further processing to the event queue based on the currently read event. This actually processes the tasks step by step. While executing one task, you can also execute another task. In this way, without affecting the main program flow, the real-time performance of the system is improved. [page]

Brief flow of the event loop

Legend: 1=EVENT_ETH_ARRIVED; 2=EVENT_TCP_RETRAN; 3=EVENT_TCP_INACTIVITY; 4=EVENT_ARP_RETRAN; 5=EVENT_AGE_ARP_CACHE; 6=EVENT_COME_NEWDATA;

Figure 2 Event loop process

The brief flow of the event loop is shown in Figure 2, where the meanings of each event are as follows:

EVENT_ETH_ARRIVED: An Ethernet frame event to be processed. Upon detecting this event, C8051F040 will call the program to read the CP2200 receiving buffer, and then unpack the frame;

EVENT_TCP_RETRAN: TCP retransmission event. This event is triggered when the TCP timer times out;

EVENT_TCP_INACTIVITY: Inactive connection shutdown event. This event is triggered when a connection has not sent or received data for more than 0.5 seconds;
EVENT_ARP_RETRAN: ARP request packet retransmission event. This event is triggered when an ARP request has no response after 0.5 seconds. If there is no response after two retransmissions, the data packet with the IP as the destination address will be discarded;

EVENT_AGE_ARP_CACHE: Update ARP cache event. This event is triggered every 60 seconds;

EVENT_COME_NEWDATA: New data event. When there is new data to be sent, this event is triggered;

Conclusion

The various integrated functions of CP2200, such as CRC check and data filtering, effectively reduce the load of the microcontroller. Its internal transceiver interface unit is flexible and convenient to operate, providing effective buffering for Ethernet data packets. The chip has stable working performance and anti-interference and anti-vibration performance. The author has developed an Ethernet communication interface board for railway locomotives using CP2200, C8051F040 microcontroller and TCP/IP protocol stack. This board has been running on the test locomotive, with good working performance and stable data transmission.

References:
1. Silicon Laboratories Inc. CP2200 datasheet. http://www.silabs.com/
2. Silicon Semiconductor Inc. c8051f040 datasheet. http://www.silabs.com/
3. Special Edition Using TCP/IP, Ramadas Shanmugam ,R.Padmini,S.Nivedita, translated by Yin Haoqiong and Li Jian, Electronic Industry Press
4. TCP/IP Xiangjie Volume 2 Implementation, W.Richard Stevens http://www.china.pub.com/

Keywords:CP2200 Reference address:A reliable and low-cost embedded Ethernet interface design

Previous article:C8051F30x MCU Low-cost RF card reader solution
Next article:A signal processing circuit design for SAW RFID reader

Latest Microcontroller 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号