AVR MCU controls RTL8019AS to implement Ethernet interface design

Publisher:静心静气Latest update time:2020-02-20 Source: eefocusKeywords:AVR Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Design of Ethernet Interface Based on AVR High-Performance MCU

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:

Design of Ethernet Interface Based on AVR High-Performance MCU

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.

[1] [2]
Keywords:AVR Reference address:AVR MCU controls RTL8019AS to implement Ethernet interface design

Previous article:AVR external interrupt experimental program
Next article:Power-off protection of AVR microcontroller

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号