Application of Embedded TCP/IP Protocol Microcontroller Technology in Network Communication

On the Internet, the TCP/IP protocol guarantees accurate data transfer every moment. In the field of data collection, how to use the TCP/IP protocol to transmit data in the network has become a hot topic. In this system, the author successfully realized the network interconnection of the MCU by using UDP (User Datagram Protocol), IP (Network Message Protocol), ARP (Address Resolution Protocol) and simple application layer protocol in TCP/IP protocol. It not only improves the speed of data transmission, but also ensures the correctness of data transmission, and also expands the effective radius of data transmission.

1 Introduction to TCP/IP Protocol

The TCP/IP protocol is a set of protocols that interconnect various systems on the Internet to ensure accurate and fast data transfer over the Internet. Referring to the Open Systems Interconnection (OSI) model, TCP/IP usually adopts a simplified four-layer model: application layer, transport layer, network layer, and link layer.

(1) Application layer: The network application layer should have a clearly defined session process, such as Http, Ftp, Telnet, etc. In this system, the MCU system transmits data from Ethernet and data terminals, and the application layer only processes the large datagrams for packetization and disassembly.

(2) Transport layer: The transport layer allows the network program to obtain data through clearly defined channels and certain characteristics, such as defining the port number of the network connection, etc., to implement the transmission control protocol TCP and the user data protocol UDP of the layer protocol. The UDP datagram protocol is used in this system.

(3) Network layer: The network layer allows information to be sent to any host on an adjacent TCP/IP network. The IP protocol is the mechanism for transmitting data in this layer. At the same time, establish interconnection between networks, and provide an ARP address resolution protocol to implement an image from the IP address to the physical address of the data link.

(4) Link layer: It consists of the underlying protocol that controls data transmission between different machines on the same physical network. The protocol that implements this layer protocol belongs to the TCP/IP protocol group. In this system, this part of the function is realized by the single chip control network card chip CS8900.

Hardware block diagram

2 hardware block diagram

As shown in Figure 1, the system provides an RJ45 interface to connect to the Ethernet network and provides a serial port for users to use. The system board can unpack the IP datagram sent from Ethernet and send it to the serial port. It can also encapsulate the data coming from the serial port into an IP packet and send it to the LAN. The external RAM uses 61C1024 (128KB), which provides a large buffer for data processing; using E2PROM - X25045, can be used as a watchdog, or save the IP address, network card physical address and other parameters. The CS8900 chip is a LAN processing chip produced by Cirrus Logic. Its package is 100-pin TQFP. It integrates on-chip RAM, 10BASE-T transceiver filter, and provides 8-bit and 16-bit interfaces. Introduce its 8-bit mode. The NE103 is a pulse transformer that performs pulse waveform conversion on the network signal at the front end of the CS8900.

3 Working principle

3.1 How does the CS8900 work?

The CS8900 and the MCU are connected in 8-bit mode. The default working mode of the NIC chip is I/O connection. The base address is 300H. The following describes the main working registers (the numbers in parentheses after register are relative to the register address). The offset of the base address 300H).

%26;#183;LINECTL(0112H): LINECTL determines the basic configuration and physical interface of the CS8900. In this system, set the initial value to 00d3H, select the physical interface as 10BASE-T, and enable the transmit and receive control bits of the device.

%26;#183; RXCTL (0104H): The RXCTL controls the CS8900 to receive specific datagrams. Set the initial value of RXTCL to 0d05H, and receive the correct datagram on the network with the same broadcast or destination address as the local physical address.

%26;#183;RXCFG(0102H): RXCFG controls the CS8900 to trigger a receive interrupt after receiving a specific datagram. RXCFG can be set to 0103H, so that when a correct datagram is received, the CS8900 will generate a receive interrupt.

%26;#183;BUSCT(0116H): BUSCT can control some operations of the chip's I/O interface. Set the initial value to 8017H and turn on the CS8900's interrupt total control bit.

%26;#183;RXCFG(0102H): RXCFG controls the CS8900 to trigger a receive interrupt after receiving a specific datagram. RXCFG can be set to 0103H, so that when a correct datagram is received, the CS8900 will generate a receive interrupt.

%26;#183;BUSCT(0116H): BUSCT can control some operations of the chip's I/O interface. Set the initial value to 8017H and turn on the CS8900's interrupt total control bit.

%26;#183;RXCFG(0102H): RXCFG controls the CS8900 to trigger a receive interrupt after receiving a specific datagram. RXCFG can be set to 0103H, so that when a correct datagram is received, the CS8900 will generate a receive interrupt.

%26;#183;BUSCT(0116H): BUSCT can control some operations of the chip's I/O interface. Set the initial value to 8017H and turn on the CS8900's interrupt total control bit.

%26;#183;ISQ(0120H): ISQ is the interrupt status register of the NIC chip. The internal map receives the contents of the interrupt status register and the transmit interrupt status register.

%26;#183; PORT0 (0000H): When transmitting and receiving data, the CPU passes data through PORT0.

%26;#183;TXCMD(0004H): Transmit control register. If data 00C0H is written, the network card chip starts to send data after all data is written.

%26;#183;TXLENG(0006H): Transmit data length register. When sending data, first write the length of the transmission data, then write the data to the chip through PORT0.

The above are the most important working registers (16 bits). The CS8900 supports 8-bit mode. When reading or writing 16-bit data, the lower byte corresponds to the even address, and the upper byte corresponds to the odd address. For example, if 00C0H is written to TXCMD, 00h can be written to 305H and C0H can be written to 304H. When the system works, the NIC chip should be initialized first, that is, write registers LINECTL, RXCTL, RCCFG, BUSCT. When sending data, write control register TXCMD, and write the data length to TXLENG, then write the data to PORT0 port sequentially, such as writing the first byte to 300H, the second byte to 301H, the third The byte is written to 300H, and so on. The NIC chip organizes the data into the link layer type and adds the padding bit and the CRC check to the network. The MCU queries the ISO data, and when the data arrives, reads the received data frame. When reading data, the MCU reads the addresses 300H, 301H, 300H, 301H... in sequence.

3.2 MCU workflow

As shown in the figure, the microcontroller first initializes the network device. The NIC IP address and physical address are stored in the X25045. After the MCU resets, the data is first read to initialize the network.

MCU workflow

The MCU mainly completes the unpacking and packaging of the data. When there is data coming from RJ45, the MCU analyzes the datagram. If it is an ARP (Physical Address Resolution) packet, the program is transferred to the ARP handler (because the ARP protocol maps the IP address and the physical address on the network) . If it is an IP data packet and the transport layer uses the UDR protocol and the port is correct, the datagram is considered correct. After the data is unpacked, the data portion is output through the serial port. Conversely, if the MCU receives data from the serial port, it will be packaged according to the UDP protocol format and sent to the CS8900. The CS8900 will output the data to the LAN. It can be known that the MCU mainly processes the network layer and the transport layer of the protocol, and the link layer part is completed by the CS8900. Since the MCU outputs the data through the serial port completely after receiving the data, the application layer is delivered to the user for processing, and the user can process the received data according to the requirements. In the program processing of the microcontroller, the complete APR address resolution protocol is included. Through the correct setting of gateway, subnet mask and other parameters in the single-chip microcomputer, data communication between the local area network device and the terminal device on the external Internet is realized.

4 applications

The single-chip system board with embedded TCP/IP protocol has the advantages of low cost, less hardware, less occupied area, fast transmission speed and convenient use. Applicable to existing network transmission systems, it has broad application prospects, especially in the field of data acquisition and data transmission. Currently, it is used in screen data imaging and remote data acquisition systems.

Heat power setting:400/800/1200W        

Automatic tip-off protection          

Oscillating function with handle,easy to be taken

Halogen tube is a sealed light-emitting tube, filled with halogen element inert gas, the middle of the tungsten wire white, black two (due to the cost of white tungsten wire is much higher than the black tungsten wire, so the market is not universal ). Halogen tube with high thermal efficiency, heating is not oxidation, long life and other advantages, and some models also attached to the timing, rotation, humidification and other functions. Halogen tube heater is to rely on luminous heat dissipation, the general use of 2 to 3 halogen tube for the heat source, the power consumption of 900 ~ 1200W or so, more suitable for the area of about 12 square meters of the room, some of the more advanced products with automatic Power, automatic shaking his head and other functions, simple and practical design.

Halogen Heater

Halogen Heater, Electric Halogen Heater, Halogen Room Heater, Portable Halogen Heater

Ningbo APG Machine(appliance)Co.,Ltd , http://www.apgelectrical.com