The data transmission technology of embedded TCP / IP single chip microcomputer in network communication is introduced. The TCP / IP protocol is embedded in the single chip microcomputer, and the data transmission of the single chip microcomputer in the local area network and the Internet through the local area network is realized by using the network card chip CS8900. The user terminal uses the single-chip microcomputer system board as the medium to realize data communication with the remote data terminal through the network.

Keywords: TCP / IP protocol MCU Internet LAN chip

On the Internet, the TCP / IP protocol ensures accurate data transmission at all times. In the field of data collection, how to use TCP / IP protocol for data transmission in the network has become a hot topic. In this system, I use UDP (User Datagram Protocol), IP (Network Message Protocol), ARP (Address Resolution Protocol) and simple application layer protocol in the TCP / IP protocol to successfully implement the network interconnection of the microcontroller 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 transmission of data on the Internet. Referring to the Open System Interconnection (OSI) model, TCP / IP usually uses a simplified four-layer model, namely: application layer, transport layer, network layer, link layer.

(1) Application layer

The network application layer must have a clearly defined conversation process, such as the so-called Http, Ftp, Telnet and so on. In this system, the SCM system transfers data from Ethernet and data terminals, and the application layer only packs and disassembles the large datagrams.

(2) Transport layer

The transport layer allows network programs to obtain data through clearly defined channels and certain features, such as defining the port number of the network connection, etc., to implement the transmission control protocol TCP and user data protocol UDP of this layer of protocols. The UDP datagram protocol is used in this system.

(3) Network layer

The network layer allows information to be sent to any host on the adjacent TCP / IP network. The IP protocol is the mechanism for transmitting data in this layer. At the same time to establish the interconnection between networks, ARP address resolution protocol should be provided to realize the mapping from IP address to data link physical address.

(4) Link layer

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

2 Hardware block diagram

As shown in Figure 1, the system provides 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 from Ethernet and send it to the serial port, or it can encapsulate the data from the serial port as an IP packet and send it to the local area network. The external RAM uses 61C1024 (128KB), which provides a large cache for data processing; use E2PROM-X25045, can be used as a watchdog, you can also save the IP address, physical address of the network card and other parameters.

The CS8900 chip is a LAN processing chip produced by Cirrus Logic. Its package is 100-pin TQFP, which integrates on-chip RAM, 10BASE-T transceiver filter, and provides 8-bit and 16-bit interfaces. Introduce its 8-bit mode.

NE103 is a pulse transformer that transforms the pulse waveform of the network signal at the front end of the CS8900.

3 Working principle

3.1 The working principle of CS8900

The CS8900 is connected to the single-chip computer in an 8-bit mode. The default working mode of the network card chip is I / O connection after reset. The base address is 300H. The main working registers are described below. Base offset of 300H).

· 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 device to send and receive control bits.

· RXCTL (0104H)

RXCTL controls the CS8900 to receive specific datagrams. Set the initial value of RXTCL to 0d05H, and receive the correct datagram with the same broadcast or target address as the local physical address.

· RXCFG (0102H)

RXCFG control CS8900 will 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.

· 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 interrupt master control bit.

· ISQ (0120H)

ISQ is the interrupt status register of the network card chip, which internally maps the contents of the receive interrupt status register and the send interrupt status register.

· PORT0 (0000H)

When sending and receiving data, the CPU passes the data through PORT0.

· TXCMD (0004H)

Send control register, if write data 00C0H, then the network card chip starts sending data after all data is written.

· TXLENG (0006H)

Send data length register, when sending data, first write the sending data length, 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 low-order byte corresponds to an even address, and the high-order byte corresponds to an odd address. For example, if you write 00C0H to TXCMD, you can write 00h to 305H and C0H to 304H.

When the system works, you should first initialize the network card chip, that is, write registers LINECTL, RXCTL, RCCFG, BUSCT. When sending data, write the control register TXCMD, and write the length of the transmitted data to TXLENG, and then write the data to the PORT0 port in sequence. Write 300H bytes, and so on. The NIC chip organizes the data into the link layer type and adds padding bits and CRC check to the network. Similarly, the microcontroller queries the ISO data and reads the received data frame when the data comes. When reading data, the MCU reads the addresses 300H, 301H, 300H, 301H ... in sequence.

3.2 SCM workflow

As shown in the figure, the MCU first initializes the network equipment. The IP address and physical address of the network card are stored in X25045. After resetting the MCU, these data are first read to initialize the network.

The single chip microcomputer mainly completes the unpacking and packaging of data. When there is data coming from RJ45, the microcontroller analyzes the datagram. If it is an ARP (Physical Address Resolution) packet, the program is transferred to the ARP handler (because it is the ARP protocol that 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 part is output through the serial port. Conversely, if the MCU receives data from the serial port, it will package the data according to the UDP protocol format, send it to the CS8900, and the CS8900 will output the data to the local area network.

It can be known that the single-chip computer mainly handles the network layer and the transmission layer of the protocol, and the link layer part is completed by the CS8900. Because the single-chip microcomputer outputs the data through the serial port intact and unchanged, the application layer is delivered to the user for processing, and the user can process the received data according to the needs.

In the program processing of the single chip microcomputer, the complete APR address resolution protocol is included. By correctly setting the parameters such as gateway and subnet mask in the single-chip microcomputer, data communication between the single-chip microcomputer and the external Internet terminal device is realized.

4 Application

This embedded TCP / IP protocol single chip microcomputer system board has the advantages of low cost, less hardware, less occupied area, fast transmission speed, and convenient use. It is applicable to the existing network transmission system and has a wide range of application prospects, especially in the fields of data acquisition and data transmission. Currently, it is used in screen panel data imaging and remote data acquisition systems.

RGB Bluetooth Speaker

Rgb Bluetooth Speaker,Rgb Light Bluetooth Speaker,Rgb Portable Speaker For Outdoor,20W Rgb Outdoor Speaker

Comcn Electronics Limited , https://www.comcnspeaker.com