The registers of page 2 are read-only, and the registers of page 3 are not compatible with NE2000, so they do not need to be set. First, select page O, and the network card chip is in stop mode. Because it has not been initialized yet, set 0x40~0x4B as the network card's send buffer, a total of 12 pages, just enough to store the two largest Ethernet data packets; 0x4C~0x7F is the network card's receive buffer, a total of 52 pages; at the beginning, the network card did not receive any data packets, so BNRY points to page 0x4C of the first receive buffer. After setting the registers of page O, switch to page 1. Since 93C46 is not used in the design, it is necessary to specify the physical address of the chip in the program, write it to the PAR register, and then start the chip to work. The read pointer BN-RY and the write pointer CURR are mainly used to control the access process of the buffer to ensure that data can be read and written correctly.
The MCU is responsible for initializing RTL8019AS and implementing network protocols by controlling RTL8019AS, performing communication tasks such as receiving and sending data. The main program is written according to the idea of Ethernet data frame sharing, that is, the MCU is used as the server, and it is placed in a listening state after initialization. When data comes from RJ45, RTL8019AS transmits it to the MCU after receiving and processing the Ethernet data frame. The MCU analyzes the data packet. If it is an ARP data packet, the program switches to the ARP processing program; if it is an IP data packet and the IP address is correct, it continues to analyze. If it is an ICMP packet, the ICMP processing program is called. If it is a UDP or TCP data packet, the data is stored or output from the serial port after unpacking. On the contrary, when there is data to be sent, the MCU packages the data according to the protocol format of each layer and sends it to the buffer area of RTL8019AS. RTL8019AS outputs the data to the local area network. The framework of the main program is as follows:
After embedding the TCP/IP protocol, Ethernet access has been achieved, but to achieve remote control, the application layer protocol needs to be implemented, which requires the support of the network layer and the transport layer. The embedded TCP/IP protocol requires simplicity at the application layer. This system implements an HTTP protocol. Due to the limited resources of the microcontroller, static web page access is adopted, and the web page code is stored in the FLASH on the chip of Mega64. The embedded system stores the data and parameters to be transmitted in the relevant position of the web page. When a client requests a connection, these data and information are sent to the browser along the TCP connection through the HTTP protocol, so that the web pages stored in the system can be accessed in the browser of the remote PC, thereby realizing remote access and control.
3. Conclusion
This article introduces a method of using AVR microcontroller to realize Ethernet interface circuit, which has few hardware circuits, simple structure and convenient use. Considering the limited resources of microcontroller, only some protocols related to needs are realized. It can be applied to occasions with low real-time requirements such as remote meter reading, remote control of information appliances, smart communities, etc. with appropriate modifications and improvements according to actual needs. In order to increase data transmission speed and perform complex TCP/IP processing, 32 KB external RAM can be expanded to improve the data throughput of microcontroller, and external RAM can also be used as input and output buffer of serial port.
Previous article:AVR external interrupt experimental program
Next article:Power-off protection of AVR microcontroller
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- 【ufun learning】Learning 5: "Basic Example 4 - USB Serial Port and PC Communication"
- [Sold] ST P-NUCLEO-IHM001 Brushless Motor Development Kit for Sale
- Among so many board games articles, which one do you like best?
- Inductor Inductive Reactance Characteristics
- RSL10 RTE add timer
- Adding 3D packaging issues
- How to set the via cover oil in Protel 99 SE PCB design software?
- Hey guys, I can't find the following libraries on Cadence's Psipce
- First look at Texas Instruments' C2000 series
- [Project source code] Digital tube companion - binary to BCD