At present, most access methods still use PC as gateway for connection. However, this is generally used in large industrial distributed control systems. If an additional PC is used for general information appliance access, it will inevitably bring high costs to the product, which is not feasible from the perspective of product economics. The method of using embedded devices to connect information appliances solves this problem well.
With the advent of the Internet era, the Internet has become an important basic information facility. The technological progress in this area has had a positive impact on all aspects of society. Many fields are constantly exploring, developing and utilizing network resources. The so-called embedded devices are generally composed of embedded microprocessors, peripherals, specific network protocols and applications. They are used to realize the remote control, monitoring and management functions of information appliances. They replace traditional PCs or gateway devices, can meet the requirements when the data volume is not large, and have the advantages of reliability, flexibility and low cost.
Proposal
From the perspective of remote online access of information appliances, there are two situations when monitoring and controlling information appliances: (1) During remote access, the communication data volume of information appliances is not large, and a communication rate of 56Kbps can meet the requirements; (2) Information appliances do not have high requirements for real-time performance, and their delay can be more than 1 second. Based on the above two conditions, when selecting embedded devices, the single-chip microcomputer SPCE061A was selected as the microprocessor for information appliances to access the Internet, and RTL8019AS was used as the driver chip for Ethernet frames, which is responsible for receiving and sending Ethernet frames. Finally, the status information is sent to the Internet and the control data is received from the Internet through the RJ45 interface. In addition, to realize the access of information appliances to the Internet, it is also necessary to have a deep understanding of the TCP/IP protocol and the network card driver.
Introduction to RTL8019AS Ethernet Controller
The RTL8019AS Ethernet controller produced by Taiwan's RealTek company occupies a considerable proportion in the 10Mbps network card market due to its excellent performance and low price.
2.1 Main performance
(1) Comply with Ethernet II and IEEE802.3 (10Base5, 10Base2, 10BaseT) standards;
(2) Full-duplex, sending and receiving can reach a rate of 10Mbps at the same time;
(3) Built-in 16KB SRAM for transmit and receive buffering, reducing the speed requirements of the main processor;
(4) Support 8/16-bit data bus, 8 interrupt request lines and 16 I/O base address selections;
(5) Supports automatic detection of UTP, AUI, and BNC, and also supports automatic polarity correction for 10BaseT topology;
(6) Allows 4 diagnostic LED pins to be programmable output;
(7) 100-pin TQFP package reduces PCB size.
The RTL8019AS can be divided into remote DMA interface, local DMA interface, MAC (media access control) logic, data encoding and decoding logic and other ports. Its internal structure is shown in Figure 1.
The ISA bus interface, also known as the remote DMA interface, refers to the bus used by the host to control and operate the RTL8019AS. The local DMA interface refers to the connection channel between the RTL8019AS and the network cable, and its function is to complete the data exchange between the controller and the network cable. The PNP (Plug and Play) logic part is mainly used to solve the connection problem with the PC. The BootROM port is used to solve the remote startup problem. The EEPROM port is used to operate the interface between RTL8019AS and EEPROM chip 24C64. SRAM is used to store the received and sent data. The MAC logic completes some control in the process of sending and receiving data. When the host wants to send data, it sends a frame of data to the send buffer memory in the Ethernet controller through the remote DMA channel, and then issues a transmission command. The Ethernet controller completes the transmission of this frame after sending the data of the previous frame. When receiving data, the serial data is composed of bytes and sent to FIFO and CRC. The sending logic gradually shifts the bytes sent by FIFO and sends them to CRC under the control of the sending clock. The CRC logic performs CRC check on the input data when receiving, and compares the result with the CRC at the end of the frame. If they are different, the frame data will be rejected. If they are the same, they will be sent to the receiving buffer. After the receiving buffer is full of a frame, the main processor is notified to read the data by interrupt or buffer flag.
2.2 I/O address allocation of RTL8019AS
The built-in 16KB SRAM of Ethernet controller can be divided into two parts: receiving buffer and sending buffer. The buffer is in frames, with 256 bytes per page. The page range of 16KB SRAM is set at 0x40-0x80. The range of receiving buffer page is set by PSTART and PSTOP registers. CURR points to the starting page of the received frame, and BNRY points to the starting page of the frame that has not been read, that is, the page address of the next frame. When CURR reaches the bottom of the receiving buffer page, which is equal to PSTOP, CURR will automatically point to PSTART. Therefore, this 16KB SRAM is designed as a ring buffer to achieve the purpose of reusability.
Hardware Description
The core of the whole system design is a 16-bit high-performance CMOS microprocessor with bus structure launched by Taiwan Lingyang Technology Co., Ltd., which can perform high-speed calculations, flexible I/O port control and efficient data operations. SPCE061A has 2K words of SRAM and 32K words of flash ROM. Compared with the existing 8-bit microprocessors, it provides higher-speed 16-bit x 16-bit multiplication operation instructions Mul and inner product operation instructions Muls. With the optimized instruction set, the throughput of SPCE061A is greatly improved, which enables the streamlined instruction set to run reliably in it. The block diagram of the system hardware circuit is shown in Figure 2.
Figure 2 System hardware circuit block diagram [page]
The hardware structure mainly includes two parts: 1. Information collection reflecting the working status of information appliances 2. After the data is compressed by the TCP/IP protocol, it is output to the Internet through the Ethernet control chip, or the control data from the Internet is received and unpacked. The system is built based on IEEE1451.2 and TCP/IP protocols, with a standardized network interface, allowing instant connection with the Internet or Ethernet network, thereby realizing direct communication between home appliances and external networks, solving the interface problem between monitoring equipment and communication networks, and providing the underlying hardware interconnection for realizing remote monitoring based on WEB.
Single chip microcomputer controls Ethernet card for data transmission
The MCU must be embedded with TCP/IP protocol when it is connected to Ethernet. It loads TCP/IP protocol to control Ethernet card for data transmission and connects to the Internet through TCP/IP protocol. The basic idea is: the operation performed at the remote control end first finds the target through the router, and then transmits it to the MCU through the ISA interface of the network card. The driver loaded in the MCU converts it into a physical frame format, and finally the TCP/IP protocol converts it into an application layer control command. Because the internal resources of the MCU are limited, the TCP/IP protocol must be streamlined to complete the Internet access task. This system uses some protocols such as ARP, RARP, IP, UDP, etc., which can ensure that the MCU is connected to Ethernet and the code volume is small enough. The MCU mainly completes the unpacking of network data and the packaging of serial port data. When Ethernet data arrives at the device, the MCU uses the query method to read and analyze the network data. If it is an ARP (physical address resolution protocol) data packet, it will be transferred to the ARP processing program and send a RARP data packet to add the IP address and physical address to the local area network to establish a mapping. If it is a UDP data packet and the IP address and port number are correct, the data packet is received, and after the data is unpacked, the data part is output through the serial port to control the field equipment. On the contrary, if the field equipment sends data to the microcontroller through the serial port, the microcontroller packages the data according to the UDP protocol format and sends it to RTL8019AS, which then outputs the data to the local area network. If needed, the data preprocessing can be completed when the serial port data is received, and then the processed data is sent to the local area network.
Software implementation part
The software design mainly includes: Ethernet controller initialization program, driver, TCP/IP protocol stack program, and system network configuration program. The Ethernet controller driver is used to set the working state of the Ethernet control chip, that is, the working mode, and allocate the buffer for sending and receiving data; the system network configuration program is used to allocate IP addresses and domain names to the monitoring system. Due to space limitations, only part of the RTL8019AS initialization code written in assembly language is given below.
.includehardware.inc; //Configuration unit definition
.publIC_init//RTL8019AS initialization subroutine
_init:
R1=0xffff; //Initialize port A as output
[P_IOA_Attrib]=R1;
[P_IOA_Dir]=R1;
R1=0xfc07; //Set IOB0~IOB2, IOB10~IOB15 as outputs, and the others as inputs
[P_IOB_Attrib]=R1;
[P_IOB_Dir]=R1;
R1=0x0001; //Select register 00H
[P_IOB_Data]=R1;
R1=0x0021; //Select register page 0, the chip does not work
[P_IOA_Data]=R1;
[P_IOB_Data]=R1;
R1=0x004c; //Set the receive buffer, the page address is 0x4c~0x7f
[P_IOA_Data]=R1;
R1=0x0001; //Select register 02H
[P_IOB_Data]=R1;
R1 = 0x0080;
[P_IOA_Data]=R1;
...
R1=0x0801; //Select register 01H
R1=0x0001; //Select register 00H
[P_IOB_Data]=R1;
R1=0x0061; //Select register page 1
[P_IOA_Data]=R1;
...
R1 = 0x0001;
[P_IOB_Data]=R1;
R1=0x0022; //Select register page 0, the chip enters working state
[P_IOA_Data]=R1;
retf; //Program returns
By using the 16-bit single-chip microcomputer SPCE061A to drive the Ethernet control chip RTL8019AS, information appliances can be connected to the Internet via an embedded gateway, and the working status of information appliances can be conveniently and cheaply sent to a remote PC for monitoring. This low-cost, high-performance solution is reliable and flexible, and is suitable for home automation devices with low communication rates and delays. Users can use the above method to give traditional home appliances the ability to access the Internet as needed.
Previous article:Application of COP8CDR9 microcontroller in multi-channel data acquisition
Next article:Detailed explanation of the concepts and important parts of learning and application of single chip microcomputers
Recommended ReadingLatest update time:2024-11-16 19:56
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Class-D amplifier TAS5731M power-on timing analysis
- Meet at the MPS Core Cloud Exhibition Hall, challenge yourself with wisdom and courage, and win exclusive gifts!
- 【Silicon Labs Development Kit Review】+PG22 Hardware Resources
- "Play Board" + Shared Bicycle Control Panel-Hardware Modification
- How is this dead time calculated?
- MSP430fr6989 serial port DMA sending experimental routine
- Live FAQ|Microchip's Trusted Platform for CryptoAuthentication Series
- 【Qinheng Trial】7. TouchKey
- Former Chairman explains the new PCIe5.0 specification. Tektronix invites you to watch and win prizes
- Today I thought of the "collection economy", office workers are very busy