Introduction
With the rapid development of the economy, the demand for electricity and the power load have increased dramatically. Harmonics, as the most important indicator in the current power grid, have an increasingly serious impact on the power system. Harmonic data can be collected and analyzed through network transmission to achieve effective monitoring of harmonics, so as to more effectively control the harm of harmonics to electronic systems.
This paper gives a specific implementation scheme of Ethernet based on STM32F207 and DM9161A, providing a convenient and efficient network implementation method for power system equipment.
1 Hardware Implementation
The Ethernet interface based on STM32F207 is essentially the process of the internal MAC unit controlling PHY, and the two transmit data through the MII/RMII interface.
MAC (Media Access Control) is the media access control sublayer protocol. This protocol is located in the lower half of the data link layer in the OSI seven-layer protocol, and is mainly responsible for controlling and connecting the physical medium of the physical layer.
PHY (Physical Layer) is a physical interface transceiver, which implements data encoding and decoding at the physical layer and directly provides usable data streams to the MAC layer.
MII (Media Independent Interface) means that any type of PHY device can work normally without redesigning or replacing the MAC hardware; RMII (Reduced Media Independant Interface) is one of the standard Ethernet PHY interfaces. The
MII data interface requires a total of 16 signals. Due to the large number of signal lines, it is more complicated to use in practice. However, RMII only requires 7 signal lines, which greatly reduces the actual physical connection and effectively reduces the complexity and cost of hardware. Therefore, this implementation uses the RMII physical layer interface.
STMicroelectronics' STM32F207 series processors come with IEEE802.3 MAC. You only need to add a PHY physical layer chip to connect to the TCP/IP network. This implementation is based on the STM32F207ZGT6 processor.
The characteristics of the STM32F207 Ethernet interface are as follows:
◆Supports 10 Mb/s and 100 Mb/s rates;
◆A dedicated DMA controller can transmit data at high speed;
◆Supports VLAN mode;
◆Half-duplex/full-duplex mode;
◆Supports MAC control layer;
◆Built-in 32-bit CRC check.
The Ethernet connection mode of STM32F207 has two interfaces: MII and RMII. The following is an overview of the hardware connection between DM9161A and STM32F207 processor using the RMII interface. [page]
STM32F207 provides a standard RMII hardware interface. You only need to make corresponding connections according to the identification in the data sheet. The connection method implemented this time is listed in Table 1.
The implementation circuit of DM9161A is shown in Figure 1. The RMII_REF_CLK signal of DM9161A is provided by the internal MCO of STM32F207, which simplifies the hardware design and reduces the hardware cost. HR911105A is the network interface of the circuit.
The circuit board of the network control part is shown in Figure 2.
[page]
2 Software ImplementationThe main work of this part is to implement the TCP/IP protocol stack on the basis of the hardware platform. Since the TCP/IP protocol stack is relatively complex and the function implementation is relatively difficult, a mature TCP/IP protocol stack is generally selected for transplantation. This time, the open source and relatively mature LwIP Ethernet protocol stack is selected.
LwIP (Light Weight IP) is an open source TCP/IP protocol stack for embedded systems developed by the Swiss Institute of Computer Science. It has strong portability and low resource requirements. It reduces the occupation of RAM on the basis of implementing the main functions of the TCP/IP protocol. Generally, it only needs a few hundred KB of RAM and about 40 KB of ROM to run, which makes the LwIP protocol stack suitable for use in low-end embedded systems. The
transplantation work is carried out on the basis of the STM32F207 Ethernet interface driver provided by ST. For the DM9161A chip, some underlying driver codes are changed, including clock configuration, port configuration and PHY address configuration. The transplantation work generally takes a few hours to complete.
LwIP provides two functions, TCP and UDP, which are more commonly used in the TCP/IP protocol stack. TCP is a connection-oriented, reliable, byte-stream-based transport layer communication protocol; UDP is a connectionless transport layer protocol in the OSI reference model, providing simple, unreliable information transmission services for transactions. TCP is generally used in situations where data reliability is required to be high, but the data transmission speed is low. UDP has a faster transmission speed, but lower reliability, and requires the application layer to ensure the validity of data arrival. In this application, the amount of data to be transmitted is small, but the reliability requirement is high, so the TCP communication mode is selected.
LwIP provides two sets of APIs: the underlying callback-based raw API and the high-level sequential model API (similar to BSD Socket).
The sequential model API provides an API for ordinary sequential programs to use the protocol stack, which is very similar to the BSD-style API and is also based on the blocking open-read-write-close mode. Since the TCP/IP protocol stack itself is based on time, the TCP/IP code and the application code must be in different threads, so this mode requires the support of the operating system.
The raw API allows the application and TCP/IP protocol stack code to be more closely integrated. The execution of the program is also event-based, using the callback function mechanism. In this way, TCP/IP code and application code run in the same thread, so this mode can be used without operating system support.
In fact, the API of the sequential model is also implemented based on the raw API. This implementation uses the raw API to reduce the demand for hardware and software resources. The raw API is event-driven and has certain advantages in data response speed.
The operation method of the raw API is basically similar to the sequential model, but the program operation mode is different, and callback programming ideas need to be adopted. The basic actions include establishing a connection, sending data, receiving data, and closing a connection. Each type provides different interface functions according to different needs.
Conclusion
After testing, transplanting the LwIP protocol stack on the STM32F207 processor and DM9161A hardware platform can realize TCP, UDP and other functions and run stably, providing a good foundation for the subsequent development of the communication network of the power system based on this platform.
Previous article:STM32 Study Notes—SysTick Timer
Next article:Design of Intelligent Monitoring System for Computer Room Based on S3C6410
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
- Could you please help me with how to calculate the VGS of this current mirror? Thank you very much!
- GigaDevice's new GD32F470xx series with TFT and Ethernet port
- MicroPython adds support for operator @
- Frequency calculation
- The chip shortage will end in 2023 and there may be overcapacity in 2024. Do you believe it?
- Can the shared power bank industry really make money?
- I have a question about the antenna. I want to ask you guys
- BlueNRG-series level 1 training materials
- Motor Control Advanced 2——PID Position Control
- A detailed introduction to the control technology of various DC motors