Ethernet implementation scheme of STM32F207 and DM9161A

Publisher:EtherealLightLatest update time:2013-01-24 Source: 现代电子技术 Keywords:STM32F207  DM9161A  Ethernet Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

c.JPG

    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.

c.JPG

    The circuit board of the network control part is shown in Figure 2.

b.JPG[page]

2 Software Implementation
    The 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.
Keywords:STM32F207  DM9161A  Ethernet Reference address:Ethernet implementation scheme of STM32F207 and DM9161A

Previous article:STM32 Study Notes—SysTick Timer
Next article:Design of Intelligent Monitoring System for Computer Room Based on S3C6410

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号