Electoday 2025

ไมโครคอนโทรลเลอร์ => ARM Processors => Topic started by: tha on February 11, 2021, 08:40:30 AM

Title: STM32F1 ETHERNET
Post by: tha on February 11, 2021, 08:40:30 AM
29 Ethernet (ETH): media access control (MAC) with DMA controller

Low-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 16 and 32 Kbytes.
Medium-density devices are STM32F101xx, STM32F102xx and STM32F103xx
microcontrollers where the Flash memory density ranges between 64 and 128 Kbytes.
High-density devices are STM32F101xx and STM32F103xx microcontrollers where the
Flash memory density ranges between 256 and 512 Kbytes.
XL-density devices are STM32F101xx and STM32F103xx microcontrollers where the
Flash memory density ranges between 768 Kbytes and 1 Mbyte.
Connectivity line devices are STM32F105xx and STM32F107xx microcontrollers.

section นี้ใช้เฉพาะกับ STM32F107xx connectivity line devices เท่านั้น.

29.1 Ethernet introduction

Portions Copyright (c) 2004, 2005 Synopsys, Inc. สงวนลิขสิทธิ์ ใช้โดยได้รับอนุญาต

The Ethernet peripheral เปิดการใช้งาน the STM32F107xx เพื่อ transmit and receive data บน Ethernet เป็นไปตาม the IEEE 802.3-2002 standard

The Ethernet จัดให้มี a configurable, flexible peripheral เพื่อตรงตามความต้องการของหลากหลาย applications and customers. มันรองรับ two industry standard ที่อินเตอร์เฟสถึง the external physical layer (PHY): the default media independent interface (MII) ที่กำหนดใน the IEEE 802.3 specifications และ the reduced media independent interface (RMII). มันสามารถถูกใช้ในจำนวนของ applications อย่างเช่น switches, network interface cards, ฯลฯ.

The Ethernet เป็นไปตามมาตรฐานต่อไปนี้:
•    IEEE 802.3-2002 for Ethernet MAC
•    IEEE 1588-2002 standard for precision networked clock synchronization
•    AMBA 2.0 for AHB Master/Slave ports
•    RMII specification from RMII consortium
Title: Re: STM32F1 ETHERNET
Post by: tha on February 11, 2021, 11:48:32 AM
29.2 Ethernet main features

The Ethernet (ETH) peripheral ประกอบด้วยคุณสมบัติดังต่อไปนี้, แสดงตามหมวดหมู่:

29.2.1 MAC core features

•    รองรับ 10/100 Mbit/s data transfer rates ด้วย external PHY interfaces
•    IEEE 802.3-compliant MII interface เพื่อสื่อสารกับ an external Fast Ethernet PHY
•    รองรับทั้ง full-duplex และ half-duplex operations
      –    รองรับ CSMA/CD Protocol สำหรับ half-duplex operation
      –    รองรับ IEEE 802.3x flow control สำหรับ full-duplex operation
      –    มีทางเลือกการส่งต่อของ received pause control frames ไปยัง the user application ใน full-duplex operation
      –    Back-pressure รองรับสำหรับ half-duplex operation
      –    การส่งโดยอัตโนมัติของ zero-quanta pause frame บนการยกเลิกถือสิทธิ์ของ flow control input ใน full-duplex
            operation
•    Preamble และ start-of-frame data (SFD) insertion ใน Transmit, และการลบออกใน Receive paths
•    Automatic CRC และ pad generation ควบคุมได้บน a per-frame basis
•    มีทางเลือกสำหรับ automatic pad/CRC ลอกออกบน receive frames
•    ความยาวเฟรมที่โปรแกรมได้เพื่อรองรับ Standard frames ด้วยขนาดสูงถึง 16 KB
•    Programmable interframe gap (40-96 bit times ในขั้นของ 8 )
•    รองรับได้หลากหลาย flexible address filtering modes:
      –    สูงถึง four 48-bit perfect (DA) address filters พร้อมการบังสำหรับแต่ละ byte
      –    สูงถึง three 48-bit SA address comparison check พร้อมการบังสำหรับแต่ละ byte
      –    64-bit Hash filter (ทางเลือก) สำหรับ multicast and unicast (DA) addresses
      –    ตัวเลือกเพื่อส่งผ่านทุก multicast addressed frames
      –    Promiscuous mode รองรับเพื่อส่งผ่านทุก frames โดยไม่มีการกรองใดๆสำหรับ network monitoring
      –    ส่งผ่านทุก incoming packets (ตามต่อ filter) พร้อมด้วย a status report
•    32-bit status แยกกันที่ส่งคืนสำหรับ transmission and reception packets
•    รองรับ IEEE 802.1Q VLAN tag detection สำหรับ reception frames
•    ที่แยกกัน transmission, reception, and control interfaces ให้กับ the Application
•    รองรับ mandatory network statistics ด้วย RMON/MIB counters (RFC2819/RFC2665)
•    MDIO interface สำหรับ PHY device configuration และ management
•    การตรวจพบของ LAN wakeup frames และ AMD Magic Packet™ frames
•    Receive feature สำหรับ checksum off-load สำหรับ received IPv4 และ TCP packets ที่ถูกห่อหุ้มโดย the Ethernet
      frame
•    Enhanced receive feature สำหรับการเช็ค IPv4 header checksum และ TCP, UDP, หรือ ICMP checksum ที่ถูกห่อหุ้มใน
      IPv4 or IPv6 datagrams
Title: Re: STM32F1 ETHERNET
Post by: tha on February 11, 2021, 02:14:06 PM
•    รองรับ Ethernet frame time stamping ดังอธิบายใน IEEE 1588-2002. Sixty-four-bit time stamps ถูกให้ในแต่ละ
      frame's transmit or receive status
•    สองเซ็ตของ FIFOs: a 2-KB Transmit FIFO พร้อมด้วยความสามารถขอบเขตที่ตั้งโปรแกรมได้, และ a 2-KB Receive FIFO พร้อม
      ด้วยขอบเขตที่กำหนด่าได้ (ค่าเริ่มต้นคือ 64 bytes)
•    Receive Status vectors ถูกแทรกลงใน the Receive FIFO หลังจาก the EOF transfer เปิดการใช้งาน multiple-frame
      storage ใน the Receive FIFO โดยไม่มีความต้องการ FIFO อื่นเพื่อเก็บ frames' Receive Status เหล่านั้น
•    ทางเลือกเพื่อ filter ทุก error frames บน reception และไม่ส่งต่อพวกมันไปยัง the application ใน Store-and-Forward
      mode
•    ทางเลือกเพื่อส่งต่อ under-sized good frames
•    รองรับ statistics โดยการสร้าง pulses สำหรับ frames dropped หรือเสียหาย (เนื่องจาก overflow) ใน the Receive FIFO
•    รองรับ Store and Forward mechanism สำหรับ transmission ไปยัง the MAC core
•    การสร้างโดยอัตโนมัติของ PAUSE frame control หรือ back pressure signal ไปยัง the MAC core บนฐานของ Receive
      FIFO-fill (ขอบเขตที่กำหนดค่าได้) level
•    รับมือการส่งซ้ำโดยอัตโนมัติของ Collision frames สำหรับ transmission
•    ละทิ้ง frames บน late collision, excessive collisions, excessive deferral และ underrun conditions
•    Software control เพื่อล้าง Tx FIFO
•    คำนวณและใส่ IPv4 header checksum และ TCP, UDP, or ICMP checksum ใน frames ที่ถูกส่งใน Store-and-Forward
      mode
•    รองรับ internal loopback บน the MII สำหรับ debugging
Title: Re: STM32F1 ETHERNET
Post by: tha on February 12, 2021, 07:57:10 AM
29.2.2 DMA features

•    รองรับทุก AHB burst types ใน the AHB Slave Interface
•    Software สามารถเลือกประเภทของ AHB burst (fixed หรือ indefinite burst) ใน the AHB Master interface
•    ทางเลือกเพื่อเลือก address-aligned bursts จาก AHB master port
•    ทำให้เหมาะที่สุดสำหรับ packet-oriented DMA transfers ด้วย frame delimiters
•    Byte-aligned addressing สำหรับ data buffer support
•    Dual-buffer (วงแหวน) หรือ linked-list (โซ่) descriptor chaining
•    Descriptor architecture, ยอมให้ large blocks of data transfer ด้วย minimum CPU intervention;
•    แต่ละ descriptor สามารถส่งถ่ายได้สูงถึง 8 KB of data
•    Comprehensive status reporting สำหรับ normal operation และ transfers with errors
•    Individual programmable burst size สำหรับ Transmit and Receive DMA Engines เพื่อทำให้เหมาะ host bus
      utilization
•    Programmable interrupt options สำหรับ different operational conditions
•    Per-frame Transmit/Receive complete interrupt control
•    Round-robin หรือ fixed-priority arbitration ระหว่าง Receive and Transmit engines
•    Start/Stop modes
•    Current Tx/Rx Buffer pointer เป็น status registers
•    Current Tx/Rx Descriptor pointer เป็น status registers
Title: Re: STM32F1 ETHERNET
Post by: tha on February 12, 2021, 09:26:35 AM
29.2.3 PTP features

•    Received and transmitted frames time stamping
•    Coarse and fine correction methods
•    Trigger interrupt เมื่อ system time มาเป็นมากกว่า target time
•    Pulse ต่อ second output (product alternate function output)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 12, 2021, 09:41:57 AM
29.3 Ethernet pins

Table 209 แสดง the MAC signals และ the corresponding MII/RMII default(ค่าเริ่นต้น) หรือ remapped(เปลี่ยนขาใหม่) signals. มันยังแสดงให้เห็น the pins ที่ the signals เป็น input หรือ output, และ the pin configuration

(https://i.imgur.com/Cgv1sOE.png)

(https://i.imgur.com/DyGtkaZ.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 12, 2021, 10:24:34 AM
29.4 Ethernet functional description: SMI, MII and RMII

The Ethernet peripheral ประกอบด้วย a MAC 802.3 (media access control) พร้อมด้วย a dedicated DMA controller. มันรองรับทั้ง default media-independent interface (MII) และ reduced media-independent interface (RMII) ผานทาง one selection bit (อ้างอิงถึง AFIO_MAPR register).

The DMA controller อินเตอร์เฟสกับ the Core and memories ผ่านทาง the AHB Master and Slave interfaces. The AHB Master Interface ควบคุม data transfers ในขณะที่ the AHB Slave interface เข้าถึง Control and Status Registers (CSR) space.

The Transmit FIFO (Tx FIFO) บัฟเฟอร์ data ที่อ่านจาก system memory โดย the DMA ก่อน transmission โดย the MAC Core. ในทำนองเดียวกัน, the Receive FIFO (Rx FIFO) เก็บ the Ethernet frames ที่รับจาก the line จนกระทั่งพวกมันถูกส่งถ่ายไปยัง system memory โดย the DMA.

The Ethernet peripheral ยังมี an SMI เพื่อสื่อสารกับ external PHY. A set of configuration registers ยอมให้ผู้ใช้เลือก the desired mode และคุณลักษณะสำหรับ the MAC และ the DMA controller.

Note: The AHB clock frequency ต้องเป็นอย่างน้อย 25 MHz เมื่อ the Ethernet ถูกใช้.

(https://i.imgur.com/XNL5f2n.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 13, 2021, 07:24:54 AM
29.4.1 Station management interface: SMI

The station management interface (SMI) ยอมให้ the application เข้าถึง any PHY registers ผ่านทาง a 2-wire clock and data lines. The interface รองรับการเข้าถึงสูงถึง 32 PHYs.

The application สามารถเลือก one of the 32 PHYs และ one of the 32 registers ภายใน any PHY และส่ง control data หรือ receive status information. เพียง one register ใน one PHY สามารถถูกระบุตำแหน่งในเวลาใดก็ได้

ทั้ง the MDC clock line และ the MDIO data line ถูกจัดให้มีใช้เป็น alternate function I/O ใน the microcontroller:
•    MDC: a periodic clock ที่จัดให้มี the timing reference สำหรับ the data transfer ที่ความถี่สูงสุด 2.5 MHz. The
      minimum high และ low times สำหรับ MDC ต้องเป็น 160 ns แต่ละ , และ the minimum period สำหรับ MDC ต้องเป็น 400
      ns. ใน idle state the SMI management interface ขับ the MDC clock signal ต่ำ(low).
•    MDIO: data input/output bitstream เพื่อส่งถ่าย status information ไปยัง/จาก the PHY device ซิงโครไนส์กันกับ the
      MDC clock signal

(https://i.imgur.com/avv5bdQ.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 13, 2021, 10:01:30 AM
SMI frame format

The frame structure ที่เกี่ยวข้องกับ a read or write operation ถูกแสดงใน Table 13, ลำดับของ bit transmission จะต้องจากซ้ายไปขวา.

(https://i.imgur.com/CfXdrWO.png)

The management frame ประกอบด้วย eight fields:
•    Preamble: แต่ละ transaction (read or write) สามารถถูกเริ่มต้นด้วย the preamble field ที่ตรงกันกับ 32 บิตลอจิกหนึ่งที่ต่อ
      เนื่องกันบน the MDIO line ด้วย 32 corresponding cycles บน MDC. field นี้ถูกใช้เพื่อสร้าง synchronization กับ the PHY
      device.
•    Start: the start of frame ถูกกำหนดโดย a <01> pattern เพื่อตรวจสอบ transitions บน the line จากลอจิกค่าเริ่มต้นหนึ่ง
      สถานะเป็นศูนย์และกลับเป็นหนึ่ง.
•    Operation: กำหนดประเภทของ transaction (read or write)  ที่กำลังดำเนินการ
•    PADDR: the PHY address คือ 5 bits, ยอมให้ 32 unique(ไม่ซ้ำกัน) PHY addresses. The MSB bit of the address เป็น
      the first transmitted and received.
•    RADDR: the register address คือ 5 bits, ยอมให้ 32 individual registers ถูกระบุตำแหน่งภายใน the selected PHY
      device. The MSB bit of the address เป็น the first transmitted and received.
•    TA: the turn-around field กำหนด a 2-bit pattern ระหว่าง the RADDR and DATA fields เพื่อหลีกเลี่ยงความขัดแย้งใน
      ระหว่าง a read transaction. สำหรับ a read transaction the MAC controller ขับ high-impedance บน the MDIO line
      สำหรับr the 2 bits of TA. The PHY device ต้องขับ a high-impedance state บน the first bit of TA, a zero bit บนบิตที่
      สอง. สำหรับ a write transaction, the MAC controller ขับ a <10> pattern ในระหว่าง the TA field. The PHY device
      ต้องขับ a high-impedance state สำหรับ the 2 bits of TA.
•    Data: the data field คือ 16-bit. The first bit transmitted and received ต้องเป็น bit 15 ของ the ETH_MIID register.
•    Idle: the MDIO line ถูกขับใน high-impedance state. All three-state drivers ต้องถูกปิดการใช้งานและ the PHY's pull-
      up resistor เก็บ the line ที่ logic one.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 13, 2021, 10:45:25 AM
SMI write operation

เมื่อ the application เซ็ต the MII Write และ Busy bits (ใน Ethernet MAC MII address register (ETH_MACMIIAR)), the SMI เริ่มต้น a write operation ลงใน the PHY registers โดยการส่งถ่าย the PHY address, the register address in PHY, และ the write data (in Ethernet MAC MII data register (ETH_MACMIIDR). The application ไม่ควรเปลี่ยน the MII Address register contents หรือ the MII Data register ในขณะที่ the transaction กำลังดำเนินการอยู่. Write operations ไปยัง the MII Address register หรือ the MII Data Register ในระหว่างคาบเวลานี้จะถูกเพิกเฉย (the Busy bit เป็น high), และ the transaction เสร็จสมบูรณ์โดยไม่มี error ใดๆ. หลังจาก the Write operation เสร็จสมบูรณ์แล้ว, the SMI แสดงให้เห็นนี้โดยการรีเซ็ต the Busy bit.

Figure 329 แสดง the frame format สำหรับ the write operation.

(https://i.imgur.com/s2Z6spm.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 13, 2021, 11:23:22 AM
SMI read operation

เมื่อผู้ใช้เซ็ต the MII Busy bit in the Ethernet MAC MII address register (ETH_MACMIIAR) พร้อมด้วย the MII Write bit ที่ 0, the SMI เริ่มต้น a read operation in the PHY registers โดยการส่งถ่าย the PHY address and the register address in PHY. The application ไม่ควรเปลี่ยน the MII Address register contents หรือ the MII Data register ในขณะที่ the transaction กำลังดำเนินการอยู่. Write operations ไปยัง the MII Address register หรือ MII Data Register ในระหว่างคาบเวลานี้จะถูกเพิกเฉย (the Busy bit เป็น high) และ the transaction เสร็จสมบูรณ์โดยไม่มี error ใดๆ. หลังจาก the read operation เสร็จสมบูรณ์แล้ว, the SMI รีเซ็ต the Busy bit และจากนั้นอัปเดต the MII Data register ด้วย the data read จาก the PHY.

Figure 330 แสดง the frame format สำหรับ the read operation.

(https://i.imgur.com/D5E8mwJ.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 13, 2021, 11:47:51 AM
SMI clock selection

The MAC เริ่มต้น the Management Write/Read operation. The SMI clock เป็น a divided clock ซึ่งแหล่งจ่ายของมันคือ the application clock (AHB clock). The divide factor ขึ้นอยู่กับ the clock range ที่เซ็ตใน the MII Address register.

Table 211 แสดงวิธีการเซ็ต the clock ranges.

(https://i.imgur.com/xFBH1sJ.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 14, 2021, 06:57:48 AM
29.4.2 Media-independent interface: MII

The media-independent interface (MII) กำหนด the interconnection ระหว่าง the MAC sublayer และ the PHY สำหรับ data transfer ที่ 10 Mbit/s and 100 Mbit/s.

(https://i.imgur.com/EuENciW.png)

•    MII_TX_CLK: continuous clock ที่จัดให้มี the timing reference สำหรับ the TX data transfer. The nominal
      frequency คือ: 2.5 MHz ที่ 10 Mbit/s speed; 25 MHz ที่ 100 Mbit/s speed.
•    MII_RX_CLK: continuous clock ที่จัดให้มี the timing reference สำหรับ the RX data transfer. The nominal
      frequency คือ: 2.5 MHz ที่ 10 Mbit/s speed; 25 MHz ที่ 100 Mbit/s speed.
•    MII_TX_EN: transmission enable แสดงให้เห็นว่า the MAC กำลังนำเสนอ nibbles( 4 บิต) บน the MII สำหรับ
      transmission. มันต้องถูกถือสิทธิ์ synchronously (MII_TX_CLK) กับ the first nibble(4บิต) ของ the preamble และต้องยัง
      คงถูกถือสิทธิ์ในขณะที่ nibbles ทั้งหมดที่จะถูกส่งถูภนำเสนอถึง the MII.
•     MII_TXD[3:0]: transmit data คือกลุ่มของ 4 data signals ถูกขับ synchronously โดย the MAC sublayer และตรวจ
      คุณสมบัติ (valid data) บนการถือสิทธิ์ของ the MII_TX_EN signal. MII_TXD[0] คือ the least significant bit,
      MII_TXD[3] คือ the most significant bit. ในขณะที่ MII_TX_EN ถูกยกเลิกถือสิทธิ์ the transmit data ต้องไม่มีผลกับ the
      PHY.
•    MII_CRS: carrier sense ถูกถือสิทธิ์โดย the PHY เมื่ออย่างใดอย่างหนึ่ง the transmit หรือ receive medium เป็น non idle.
      มันจะถูกยกเลิกถือสิทธิ์โดย the PHY เมื่อทั้ง the transmit และ receive media เป็น idle. The PHY ต้องทำให้แน่ใจว่า the
      MII_CS signal ยังคงถูกถือสิทธิ์ตลอดระยะเวลาของ a collision condition. สัญญานนี้ไม่ถูกต้องการเพื่อการเปลี่ยนผ่าน
      synchronously ที่เคารพต่อ the TX and RX clocks. ใน full duplex mode สถานะของสัญญานนี้ไม่สนใจสำหรับ the MAC
      sublaye
Title: Re: STM32F1 ETHERNET
Post by: tha on February 14, 2021, 08:32:24 AM
•    MII_COL: collision detection ต้องถูกถือสิทธิ์โดย the PHY เมื่อการตรวจพบของ a collision บน the medium และต้องยังคงถูก
      ถือสิทธิ์ในขณะที่ the collision condition persists. สัญญานนี้ไม่ถูกต้องการเพื่อการเปลี่ยนผ่าน synchronously ที่เคารพต่อ the
      TX and RX clocks. ใน full duplex mode สถานะของสัญญานนี้ไม่สนใจสำหรับ the MAC sublayer.
•    MII_RXD[3:0]: reception data  คือกลุ่มของ 4 data signals ถูกขับ synchronously โดย the PHY และตรวจคุณสมบัติ
      (valid data) บนการถือสิทธิ์ของ the MII_RX_DV signal. MII_RXD[0] คือ the least significant bit, MII_RXD[3] คือ the
      most significant bit. ในขณะที่ MII_RX_EN ถูกยกเลิกถือสิทธิ์และ MII_RX_ER ถูกถือสิทธิ์, a specific MII_RXD[3:0] value
      ถูกใช้เพื่อส่งถ่าย specific information จาก the PHY (ดู Table 213).
•    MII_RX_DV: receive data valid แสดงให้เห็นว่า the PHY กำลังนำเสนอ recovered and decoded nibbles(4 บิต) บน the
      MII สำหรับ reception. มันต้องถูกถือสิทธิ์ synchronously (MII_RX_CLK) กับ the first recovered nibble ของ the frame
      และต้องยังคงถูกถือสิทธิ์ตลอด the final recovered nibble. มันต้องถูกยกเลิกถือสิทธิ์ก่อน the first clock cycle ที่ตาม the final
      nibble. เพื่อรับ the frame อย่างถูกต้อง, the MII_RX_DV signal ต้องห้อมล้อม the frame, การสตาร์ทไม่ช้ากว่า the SFD
      field.
•    MII_RX_ER: receive error ต้องถูกถือสิทธิ์เป็นเวลาหนึ่งหรือมากกว่า clock periods (MII_RX_CLK) เพื่อแสดงให้เห็นไปยัง the
      MAC sublayer ว่า an error ได้ถูกตรวจพบที่ไหนสักที่ใน the frame. error condition นี้ต้องถูกตรวจคุณสมบัติโดย MII_RX_DV
      assertion ดังอธิบายใน Table 213.

(https://i.imgur.com/heKjISN.png)

(https://i.imgur.com/HiHQj7w.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 14, 2021, 11:37:56 AM
MII clock sources

เพื่อสร้างทั้ง TX_CLK and RX_CLK clock signals, the external PHY ต้องถูก clocked ด้วย an external 25 MHz ดังแสดงใน Figure 332. แทนที่จะใช้ an external 25 MHz quartz เพื่อจัดให้มี clock นี้, the STM32F10xxx microcontroller สามารถส่งออกสัญญานนี้บน MCO pin ของมัน. ในกรณีนี้, the PLL multiplier ต้องถูกกำหนดค่าเพื่อให้ได้ความถี่ที่ต้องการบน the MCO pin, จาก the
25 MHz external quartz.

(https://i.imgur.com/3DNAKnm.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 14, 2021, 03:35:49 PM
-
Title: Re: STM32F1 ETHERNET
Post by: tha on February 15, 2021, 07:21:36 AM
29.4.3 Reduced media-independent interface: RMII

The reduced media-independent interface (RMII) specification ลด the pin count ระหว่าง the microcontroller Ethernet peripheral และ the external Ethernet ใน 10/100 Mbit/s. สอดคล้องกับ the IEEE 802.3u standard, an MII ประกอบด้วย 16 pins สำหรับ data and control. The RMII specification ถูกทุ่มเทเพื่อลด the pin count มาเป็น 7 pins (a 62.5% ลดลงใน pin count).

The RMII ถูก instantiated ระหว่าง the MAC and the PHY. นี้ช่วยการแปลของ the MAC's MII ลงใน the RMII. The RMII block มีคุณสมบัติดังต่อไปนี้:
•    มันรองรับ 10-Mbit/s และ 100-Mbit/s operating rates
•    The clock reference ต้องถูกสองเท่าเป็น 50 MHz
•    The same clock reference ต้องถูกจ่ายจากภายนอกไปยังทั้ง MAC และ external Ethernet PHY
•    มันจัดให้มี independent 2-bit wide (dibit) transmit and receive data เส้นทาง

(https://i.imgur.com/sTtPD1x.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 15, 2021, 08:22:21 AM
RMII clock sources

ตามที่อธิบายใน the RMII clock sources section, the STM32F10xxxSTM32F107xx ควรจัดให้มี 50 MHz clock signal นี้บน MCO output pin ของมันและคุณจากนั้นต้องกำหนดค่า output value นี้ผ่านทาง PLL configuration.

(https://i.imgur.com/kUhhXMP.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 15, 2021, 08:57:49 AM
29.4.4 MII/RMII selection

The mode, MII or RMII, ถูกเลือกโดยใช้ the configuration bit 23, MII_RMII_SEL, in the AFIO_MAPR register. The application ต้องเซ็ต the MII/RMII mode ในขณะที่ the Ethernet controller อยู่ภายใต้ reset หรือก่อนการเปิดการใช้งาน the clocks.

MII/RMII internal clock scheme

The clock scheme ที่ต้องการเพื่อรองรับทั้ง the MII and RMII, เช่นเดียวกันกับ 10 and 100 Mbit/s operations ถูกอธิบายใน Figure 335.

(https://i.imgur.com/AEb3na1.png)

เพื่อประหยัด a pin, the two input clock signals, RMII_REF_CK and MII_RX_CLK, ถูก multiplexed บน the same GPIO pin.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 15, 2021, 10:52:49 AM
29.5 Ethernet functional description: MAC 802.3

The IEEE 802.3 International Standard สำหรับ local area networks (LANs) ใช้ the CSMA/CD (carrier sense multiple access with collision detection) เป็น the access method

The Ethernet peripheral ประกอบด้วย a MAC 802.3 (media access control) controller พร้อมด้วย media independent interface (MII) และ a dedicated DMA controller.

The MAC block จัดให้มีใช้ the LAN CSMA/CD sublayer สำหรับตระกูลต่อไปนี้ของระบบ: 10 Mbit/s and 100 Mbit/s of data rates สำหรับ baseband and broadband systems. Half and full-duplex operation modes ถูกรองรับ. The collision detection access method มีให้ใช้เฉพาะกับ the half-duplex operation mode. The MAC control frame sublayer ถูกรองรับ.

The MAC sublayer ดำเนินการหน้าที่ต่อไปนี้ที่เกี่ยวข้องกับ a data link control procedure:
•    Data encapsulation(ห่อหุ้ม) (transmit and receive)
      –    Framing (frame boundary delimitation, frame synchronization)
      –    Addressing (การรรับมือของต้นทางและปลายทาง addresses)
      –    Error detection
•    Media access management
      –    Medium allocation (collision avoidance)
      –    Contention resolution (collision handling)

โดยทั่วไปมี two operating modes of the MAC sublayer:
•    Half-duplex mode: the stations ต่อสู้เพื่อใช้ the physical medium, โดยใช้ the CSMA/CD algorithms.
•    Full duplex mode: การส่งและการรับพร้อมกันโดยไม่มี contention resolution (CSMA/CD algorithm ไม่มีความจำเป็น) เมื่อ
      เงื่อนไขต่อไปนี้ทั้งหมดถูกตรงตาม
      –    physical medium capability เพื่อรองรับ simultaneous transmission and reception
      –    มี 2 stations จริงๆที่ต่อถึง the LAN
      –    ทั้งสอง stations ถูกกำหนดค่าสำหรับ full-duplex operation
Title: Re: STM32F1 ETHERNET
Post by: tha on February 16, 2021, 07:11:20 AM
29.5.1 MAC 802.3 frame format

The MAC block จัดให้มีใช้ the MAC sublayer และ the optional MAC control sublayer (10/100 Mbit/s) ตามที่ระบุโดย the IEEE 802.3-2002 standard.

Two frame formats ถูกระบุเพื่อ data communication systems โดยใช้ the CSMA/CD MAC:
•    Basic MAC frame format
•    Tagged MAC frame format (ส่วนขยายของ the basic MAC frame format)

Figure 337 and Figure 338 อธิบาย the frame structure (untagged and tagged) ที่ประกอบด้วยฟิลด์ต่อไปนี้:
•    Preamble: 7-byte field ถูกใช้สำหรับวัตถุประสงค์การซิงโครไนส์ (PLS circuitry) Hexadecimal value: 55-55-55-55-55-
      55-55
      Bit pattern: 01010101 01010101 01010101 01010101 01010101 01010101 01010101 (right-to-left bit
      transmission)
•    Start frame delimiter (SFD): 1-byte field ถูกใช้เพื่อแสดงให้เห็น the start of a frame.
      Hexadecimal value: D5
      Bit pattern: 11010101 (right-to-left bit transmission)
•    Destination and Source Address fields: 6-byte fields เพื่อแสดงให้เห็นปลายทางและต้นทาง station addresses ดังต่อไปนี้
      (ดู Figure 336):
      –    แต่ละ address คือ 48 bits ในความยาว
      –    The first LSB bit (I/G) ใน the destination address field ถูกใช้เพื่อแสดงให้เห็น an individual(เฉพาะราย) (I/G = 0)
            หรือ a group address (I/G = 1). A group address สามารถระบุ ไม่มี, หนึ่งหรือมากกว่า, หรือทุก the stations ที่เชื่อมต่อ
            ถึง the LAN. ใน the source address the first bit ถูกสงวนไว้และรีเซ็ตเป็น 0.
      –    The second bit (U/L) แยกความแตกต่างระหว่าง locally (U/L = 1) หรือ globally (U/L = 0) ที่บริหาร addresses.
            สำหรับ broadcast addresses บิตนี้เป็น 1 ด้วย.
      –    แต่ละ byte ของแต่ละ address field ต้องถูกส่ง least significant bit เป็นอันดับแรก

The address designation อยู่บนฐานของประเภทต่อไปนี้:
•    Individual address: นี้คือ the physical address ที่เกี่ยวข้องกับสถานีใดสถานีหนึ่งบนโดยเฉพาะบน the network.
•    Group address. A multidestination address ที่เกี่ยวข้องกับหนึ่งหรือมากกว่าหนึ่ง stations บน a given network. มีสองชนิด
      ของ multicast address:
      –    Multicast-group address: an address ที่เกี่ยวข้องกับกลุ่มของ logically related stations.
      –    Broadcast address: ความเด่น, predefined multicast address ( 1's ทั้งหมดใน the destination address field) ที่ใช้
            แสดงทุก the stations เสมอบน a given LAN.

(https://i.imgur.com/jYFPrRq.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 16, 2021, 09:14:35 AM
•    QTag Prefix: 4-byte field ที่แทรกระหว่าง the Source address field และ the MAC Client Length/Type field. field นี้เป็น
      ส่วนขยายของ the basic frame (untagged) เพื่อให้ได้มา the tagged MAC frame. The untagged MAC frames จะไม่รวม
      field นี้. ส่วนขยายสำหรับการติดแท็กมีดังต่อไปนี้:
      –    2-byte constant Length/Type field value ที่สอดคล้องกับ the Type interpretation (มากกว่า 0x0600) เท่ากับค่าของ
            the 802.1Q Tag Protocol Type (0x8100 hexadecimal). ฟิลด์คงที่นี้ถูกใช้เพื่อแยกความแตกต่าง tagged and
            untagged MAC frames.
      –    2-byte field บรรจุ the Tag control information field แบ่งย่อยดังต่อไปนี้ : a 3-bit user priority, a canonical
            format indicator (CFI) bit และ a 12-bit VLAN Identifier. ความยาวของ the tagged MAC frame ถูกยืดขยายเป็น 4
            bytes โดย the QTag Prefix
Title: Re: STM32F1 ETHERNET
Post by: tha on February 16, 2021, 10:41:13 AM
•    MAC client length/type: 2-byte field ที่มีวามหมายแตกต่างกัน (เฉพาะตัวอย่างสัมพันธ์กัน), ขึ้นอยู่กับค่าของมัน:
      –    ถ้าค่านี้น้อยกว่าหรือเท่ากับ maxValidFrame (0d1500) ดังนั้น field นี้แสดงให้เห็นจำนวนของ MAC client data bytes ที่
            บรรจุใน the subsequent data field ของ the 802.3 frame (length interpretation).
      –    ถ้าค่านี้มากกว่าหรือเท่ากับ MinTypeValue (0d1536 decimal, 0x0600) ดังนั้น field นี้แสดงให้เห็นลักษณะของ the MAC
            client protocol (Type interpretation) ที่เกี่ยวข้องกับ the Ethernet frame

โดยไม่คำนึงถึงการตีความของ the length/type field, ถ้าความยาวของ the data field น้อยกว่าค่าต่ำสุดที่จำเป็นสำหรับการทำงานอย่างเหมาะสมของ the protocol, a PAD field ถูกเพิ่มเข้ามาหลังจาก the data field แต่ก่อนถึง the FCS (frame check sequence) field. The length/type field ถูกส่งและรับด้วย the higher-order byte ก่อน.

สำหรับ length/type field values ในย่านระหว่าง maxValidLength และ minTypeValue (ไม่รวมขอบเขต), พฤติการณ์ของ the MAC sublayer ไม่ถูกระบุ: มันอาจหรืออาจไม่ถูกผ่านโดย the MAC sublayer.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 16, 2021, 11:15:34 AM
•    Data and PAD fields: n-byte data field. Full data transparency ถูกจัดให้มี, มันหมายความว่า arbitrary sequence ใดๆของ
      byte values อาจปรากฎใน the data field. ขนาดของ the PAD, ถ้ามี, ถูกกำหนดโดยขนาดของ the data field. Max and min
      length ของ the data and PAD field คือ:
      –    Maximum length = 1500 bytes
      –    Minimum length for untagged MAC frames = 46 bytes
      –    Minimum length for tagged MAC frames = 42 bytes

เมื่อ the data field length น้อยกว่าค่าต่ำสุดที่จำเป็น, the PAD field ถูกเพิ่มเข้ามาเพื่อให้เท่ากับ the minimum length (42 bytes for tagged frames, 46 bytes for untagged frames).
Title: Re: STM32F1 ETHERNET
Post by: tha on February 16, 2021, 01:13:27 PM
•    Frame check sequence: 4-byte field ที่บรรจุ the cyclic redundancy check (CRC) value. The CRC computation อยู่
      บนฐานของฟิลด์ต่อไปนี้ : source address, destination address, QTag prefix, length/type, LLC data and PAD (นั่นคือ,
      fields ทั้งหมดยกเว้น the preamble, SFD). The generating polynomial เป็นดังต่อไปนี้ :

      (https://i.imgur.com/YvM5sBo.png)

The CRC value ของ a frame ถูกคำนวณดังต่อไปนี้ :
•    The first 2 bits ของ the frame ถูกเติมเต็ม
•    The n-bits of the frame เป็นสัมประสิทธิ์ของ a polynomial M(x) ของ degree (n – 1). The first bit of the destination
      address ตรงกันกับ the (https://i.imgur.com/GJaicDF.png) term และ the last bit of the data field ตรงกันกับ the (https://i.imgur.com/oPrAivb.png) term
•    M(x) ถูกคูณด้วย x32 และถูกหารด้วย G(x), ทำให้เหลือ R(x) ของ degree ≤ 31
•    ค่าสัมประสิทธิ์ของ R(x) ถูกพิจารณาเป็น a 32-bit sequence
•    The bit sequence ถูกเติมเต็มและผลลัพธ์คือ the CRC
•    The 32-bits of the CRC value ถูกใส่ใน the frame check sequence. The (https://i.imgur.com/g3xPqqb.png) term ถูกส่งก่อน, the (https://i.imgur.com/oPrAivb.png) term ถูกส่งสุดท้าย

(https://i.imgur.com/3yFLhI7.png)

แต่ละ byte ของ the MAC frame, ยกเว้น the FCS field, ถูกส่ง low-order bit ก่อน.

An invalid MAC frame ถูกกำหนดโดยหนึ่งในเงื่อนไขต่อไปนี้ :
•    The frame length ไม่สอดคล้องกับค่าที่คาดหวังตามที่ระบุโดย the length/type field. ถ้า the length/type field บรรจุ a type
      value, ดังนั้น the frame length จะถือว่ามีความสอดคล้องกับฟิลด์นี้ (no invalid frame)
•    The frame length ไม่ใช่จำนวนเต็มของ bytes (extra bits)
•    The CRC value ที่คำนวณบน the incoming frame ไม่ตรงกับ the included FCS
Title: Re: STM32F1 ETHERNET
Post by: tha on February 17, 2021, 07:29:14 AM
29.5.2 MAC frame transmission

The DMA ควบคุม transactions ทั้งหมดสำหรับ the transmit path. Ethernet frames อ่านจาก the system memory ถูกใส่ลงใน the FIFO โดย the DMA. The frames จากนั้นถูก popped out และถูกส่งถ่ายไปยัง the MAC core. เมื่อ the end-of-frame ถูกส่งถ่าย, the status ของ the transmission ถูกได้จาก the MAC core และส่งถ่ายกลับไปยัง the DMA. The Transmit FIFO มีความลึก 2 Kbyte. FIFO-fill level ถูกแสดงให้เห็นไปยัง the DMA เพื่อว่ามันสามารถเริ่มต้น a data fetch ใน required bursts จาก the system memory, โดย the AHB interface. The data จาก the AHB Master interface ถูกใส่ลงใน the FIFO.

เมื่อ the SOF ถูกตรวจพบ, the MAC ยอมรับ the data และเริ่มการส่งไปยัง the MII. The time ที่จำเป็นเพื่อส่ง the frame data ไปยัง the MII หลังจาก the application เริ่มต้น transmission ผันแปรได้, ขึ้นอยู่กับ delay factors อย่าง IFG delay, เวลาเพื่อส่ง preamble/SFD, และ any back-off delays สำหรับ Half-duplex mode. หลังจาก the EOF ถูกส่งถ่ายไปยัง the MAC core, the core เสร็จสมบูรณ์ normal transmission และจากนั้นให้ the status of transmission กลับไปยัง the DMA. ถ้า a normal collision (in Half-duplex mode) เกิดขึ้นในระหว่าง transmission, the MAC core ทำให้ the transmit status ถูกต้อง, จากนั้นยอมรับและดร็อป data ต่อไปทั้งหมดจนกระทั่ง the next SOF ถูกรับ. The same frame จะถูกส่งซ้ำจาก SOF บนการสังเกตุ a Retry request (ใน the Status) จาก the MAC. The MAC ปล่อยออก an underflow status ถ้า the data ไม่ถูกจัดให้มีอย่างต่อเนื่องในระหว่าง the transmission. ในระหว่าง the normal transfer ของ a frame, ถ้า the MAC รับ an SOF โดยไม่ได้รับ an EOF ของ the previous frame, ดังนั้น the SOF จะถูกไม่ยอมรับรู้และ the new frame ถูกพิจารณาเป็นความต่อเนื่องของ the previous frame.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 17, 2021, 09:26:47 AM
มีสองโหมดของการทำงานสำหรับดึง data ไปยัง the MAC core:
•    ใน Threshold mode, ทันทีที่จำนวนของ bytes ใน the FIFO ข้ามระดับขอบเขตที่กำหนดค่าไว้ (หรือเมื่อ the end-of-frame ถูก
      เขียนก่อนขอบเขตจะถูกข้าม), the data พร้อมที่จะถูก popped out และส่งต่อไปยัง the MAC core. The threshold level ถูก
      กำหนดค่าโดยใช้ the TTC bits of ETH_DMABMR.
•    ใน Store-and-forward mode, เพียงหลังจาก a complete frame ถูกเก็บใน the FIFO, the frame ถูก popped ไปยัง the
      MAC core. ถ้า the Tx FIFO size น้อยกว่า the Ethernet frame ที่จะถูกส่ง, ดังนั้น the frame ถูก popped ไปยัง the MAC
      core เมื่อ the Tx FIFO มาเป็นใกล้จะเต็ม.

The application สามารถล้าง the Transmit FIFO ของสิ่งที่อยู่ภายในทั้งหมดโดยการเซ็ต the FTF (ETH_DMAOMR register [20]) bit. บิตนี้เคลียร์ด้วยตัวเองและเริ่มต้น the FIFO ชี้ไปยัง the default state. ถ้า the FTF bit ถูกเซ็ตในระหว่าง a frame ส่งถ่ายไปยัง the MAC core, จากนั้น transfer จะถูกหยุดเนื่องจาก the FIFO ถูกพิจารณาว่าว่างเปล่า. ดังนั้น an underflow event เกิดขึ้นที่ the
MAC transmitter และ the corresponding Status word ถูกส่งต่อไปยัง the DMA.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 17, 2021, 10:36:41 AM
Automatic CRC and pad generation

เมื่อจำนวนของ bytes ที่รับจาก the application ตกลงต่ำกว่า 60 (DA+SA+LT+Data), ศูนย์ถูกต่อท้ายไปยัง the transmitting frame เพื่อทำให้ the data length เท่ากับ 46 bytes เพื่อตรงตาม the minimum data field requirement of IEEE 802.3. The MAC สามารถถูกโปรแกรมไม่ต่อท้ายด้วย any padding. The cyclic redundancy check (CRC) สำหรับ the frame check sequence (FCS) field ถูกคำนวณและต่อท้ายไปยัง the data ที่กำลังถูกส่ง. เมื่อ the MAC ถูกโปรแกรมไม่มีต่อท้ายด้วย the CRC value ไปยัง the end of Ethernet frames, the computed CRC จะไม่ถูกส่ง. ข้อยกเว้นของกฎนี้คือว่าเมื่อ the MAC ถูกโปรแกรมเพื่อต่อท้าย pads สำหรับ frames (DA+SA+LT+Data) ที่น้อยกว่า 60 bytes, CRC จะถูกต่อท้ายที่ the end of the padded frames.

The CRC generator จะคำนวณ the 32-bit CRC สำหรับ the FCS field ของ the Ethernet frame. การเข้ารหัสถูกกำหนดโดยพหุนามต่อไปนี้.

(https://i.imgur.com/oXUPUtw.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 18, 2021, 07:30:26 AM
Transmit protocol

The MAC ควบคุมการทำงานของ Ethernet frame transmission. มันดำเนินการหน้าที่ต่อไปนี้เพื่อตรงตาม the IEEE 802.3/802.3z specifications. มัน :
•    สร้าง the preamble and SFD
•    สร้าง the jam pattern in Half-duplex mode
•    ควบคุม the Jabber timeout
•    ควบคุมการไหลสำหรับ Half-duplex mode (back pressure)
•    สร้าง the transmit frame status
•    บรรจุ time stamp snapshot logic สอดคล้องกันกับ IEEE 1588

เมื่อ a new frame transmission ถูกร้องขอ, the MAC ส่งออก the preamble and SFD, ตามด้วย the data. The preamble ถูกกำหนดเป็น 7 bytes of 0b10101010 pattern, และ the SFD ถูกกำหนดเป็น 1 byte of 0b10101011 pattern. The collision window ถูกกำหนดเป็น 1 slot time (512 bit times สำหรับ 10/100 Mbit/s Ethernet). The jam pattern generation สามารถใช้ได้เฉพาะกับ Half-duplex mode, ไม่กับ Full-duplex mode.

ใน MII mode, ถ้า a collision เกิดขึ้นที่เวลาใดๆจากจุดเริ่มต้นของ the frame ไปยังจุดสิ้นสุดของ the CRC field, the MAC ส่ง a 32-bit jam pattern of 0x5555 5555 บน the MII เพื่อแจ้ง stations อื่นๆทั้งหมดว่า a collision ได้เกิดขึ้น. ถ้า the collision ถูกเห็นในระหว่าง the preamble transmission phase, the MAC เสร็จสมบูรณ์ the transmission ของ the preamble and SFD และจาก
นั้นส่ง the jam pattern.

A jabber timer ถูกค้ำจุนไว้เพื่อตัด the transmission of Ethernet frames ถ้ามากกว่า 2048 (ค่าเริ่มต้น) bytes ต้องถูกส่งถ่าย. The MAC ใช้ the deferral mechanism สำหรับ flow control (back pressure) ใน Half-duplex mode. เมื่อ the application ร้องขอเพื่อหยุด frames ที่กำลังรับ, the MAC ส่ง a JAM pattern of 32 bytes เมื่อไรก็ตามที่มันสัมผัสการรับของ a frame, โดยมีเงื่อนไขว่า
transmit flow control ถูกเปิดการใช้งาน. นี้ส่งผลให้ a collision และ the remote station backs off(ถอยหลัง). The application ร้องขอ flow control โดยการเซ็ต the BPA bit (bit 0) ใน the ETH_MACFCR register. ถ้า the application ร้องขอ a frame ที่จะถูกส่ง, จากนั้นมันถูกกำหนดเวลาและถูกส่งแม้ว่าเมื่อ back pressure ถูกทำให้ทำงาน สังเกตว่าถ้า back pressure ถูกทำให้ทำงานมาเป็นเวลานาน (และมากกว่า 16 consecutive collision events เกิดขึ้น) จากนั้น the remote stations ละทิ้งการส่งของมันเนื่องจาก collisions ที่มากเกินไป. ถ้า IEEE 1588 time stamping ถูกเปิดการใช้งานสำหรับ the transmit frame, block นี้จะจับ a snapshot ของ the system time เมื่อ the SFD ถูกใส่ไปบน the transmit MII bus.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 18, 2021, 09:43:06 AM
Transmit scheduler

The MAC มีหน้าที่กำหนดเวลา the frame transmission บน the MII. มันรักษา the interframe gap ระหว่าง two transmitted frames และตามด้วย the truncated binary exponential backoff algorithm สำหรับ Half-duplex mode. The MAC เปิดการใช้งาน transmission หลังจากพอใจกับ the IFG and backoff delays. มันรักษา an idle period of the configured interframe gap (IFG bits in the ETH_MACCR register) ระหว่าง any two transmitted frames. ถ้า frames ที่จะถูกส่งมาถึงเร็วกว่า the configured IFG time, the MII คอยสำหรับ the enable signal จาก the MAC ก่อนการสตาร์ท the transmission บนมัน. The MAC สตาร์ท IFG counter ของมันทันทีที่ the carrier signal ของ the MII ไปเป็นไม่ทำงาน. ที่ the end of the programmed IFG value, the MAC เปิดการใช้งาน transmission ใน Full-duplex mode. ใน Half-duplex mode และเมื่อ IFG ถูกกำหนดค่าเป็นเวลา 96 bit times, the MAC ทำตาม the rule of deference ที่ระบุใน Section 4.2.3.2.1 of the IEEE 802.3 specification. The MAC รีเซ็ต IFG counter ของมันถ้า a carrier ถูกตรวจพบในช่วงสองในสามแรก (64-bit times สำหรับ all IFG values) ของ the IFG interval. ถ้า the carrier ถูกตรวจพบในช่วงหนึ่งในสามสุดท้ายของ the IFG interval, the MAC จะดำเนินการต่อ the IFG count และเปิดการใช้งาน the transmitter หลังจาก the IFG interval. The MAC จัดให้มีใช้ the truncated binary exponential backoff algorithm เมื่อมันทำงานใน Half-duplex mode.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 18, 2021, 10:55:35 AM
Transmit flow control

เมื่อ the Transmit Flow Control Enable bit (TFE bit in ETH_MACFCR) ถูกเซ็ต, the MAC สร้าง Pause frames และส่งพวกมันตามความจำเป็น, ใน Full-duplex mode. The Pause frame ถูกต่อท้ายด้วย the calculated CRC, และถูกส่ง. Pause frame generation สามารถถูกเริ่มต้นในสองทาง.

A pause frame ถูกส่งอย่างใดอยางหนึ่งเมื่อ the application เซ็ต the FCB bit in the ETH_MACFCR register หรือเมื่อ the receive FIFO เต็ม (packet buffer).
•    ถ้า the application ร้องขอ flow control โดยการเซ็ต the FCB bit in ETH_MACFCR, the MAC สร้างและส่ง a single Pause
      frame. ค่าของ the pause time ใน the generated frame บรรจุ the programmed pause time value ใน
      ETH_MACFCR. เพื่อยืดขยาย the pause หรือสิ้นสุด the pause ก่อนถึง the time ที่ระบุใน the previously transmitted
      Pause frame, the application ต้องร้องขอ another Pause frame transmission หลังจากการโปรแกรม the Pause Time
      value (PT in ETH_MACFCR register) ด้วยค่าที่เหมาะสม.
•    ถ้า the application ร้องขอ flow control เมื่อ the receive FIFO เต็ม, the MAC สร้างและส่ง a Pause frame. ค่าของ the
      pause time ใน the generated frame คือ the programmed pause time value ใน ETH_MACFCR. ถ้า the receive
      FIFO ยังคงเต็มที่จำนวนที่กำหนดค่าได้ของ slot-times (PLT bits in ETH_MACFCR) ก่อน Pause time นี้จะหมด, a second
      Pause frame ถูกส่ง. กระบวนการนี้ถูกทำซ้ำตราบเท่าที่ the receive FIFO ยังคงเต็ม. ถ้าเงื่อนไขนี้ไม่พอใจมากขึ้นก่อนถึง the
      sampling time, the MAC ส่ง a Pause frame ด้วย zero pause time เพื่อแสดงให้เห็นไปยัง the remote end ว่า the
      receive buffer พร้อมรับ new data frames.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 19, 2021, 07:04:10 AM
Single-packet transmit operation

ลำดับทั่วไปของเหตุการณ์สำหรับ a transmit operation เป็นดังต่อไปนี้ :
1.    ถ้า the system มี data ที่จะถูกส่งถ่าย, the DMA controller จะดึงข้อมูลจาก the memory ผ่านทาง the AHB Master interface
       และสตาร์ทส่งต่อพวกมันไปยัง the FIFO. มันจะต่อเนื่องรับ the data จนกระทั่ง the end of frame ถูกส่งถ่าย.
2.    เมื่อ the threshold level ถูกข้ามหรือ a full packet of data ถูกรับลงใน the FIFO, the frame data ถูก popped และขับไปยัง
       the MAC core. The DMA จะต่อเนื่องส่งถ่าย data จาก the FIFO จนกระทั่ง a complete packet ถูกส่งถ่ายไปยัง the MAC แล้ว.
       เมื่อ completion of the frame, the DMA controller ถูกแจ้งให้ทราบโดย the status ที่มาจาก the MAC.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 19, 2021, 07:07:15 AM
Transmit operation—Two packets in the buffer

1.    เนื่องจาก the DMA ต้องอัปเดต the descriptor status ก่อนปล่อยมันไปยัง the Host, สามารถมีได้มากที่สุดสองเฟรมภายใน a
       transmit FIFO. The second frame ถูก fetched โดย the DMA และใส่ลงใน the FIFO เฉพาะถ้า the OSF (ทำงานบน
       second frame) bit ถูกเซ็ต. ถ้าบิตนี้ไม่ถูกเซ็ต, the next frame ถูก fetched จาก the memory เฉพาะหลังจาก the MAC ได้
       กระบวนการ the frame เสร็จสมบูรณ์แล้วและ the DMA ได้ปลดปล่อย the descriptors.
2.    ถ้า the OSF bit ถูกเซ็ต, the DMA สตาร์ทการดึง the second frame โดยทันทีหลังจากเสร็จสิ้นการส่งถ่ายของ the first frame
       ไปยัง the FIFO. มันไม่รอให้ the status ถูกปรับปรุง. ในระหว่างนี้, the second frame ถูกรับลงใน the FIFO ในขณะที่ the first
       frame กำลังถูกส่ง. ทันทีที่ the first frame ถูกส่งถ่ายแล้วและ the status ถูกรับจาก the MAC, มันถูกผลักไปยัง the DMA. ถ้า
       the DMA เสร็จสิ้นการส่ง the second packet ไปยัง the FIFO แล้ว, the second transmission ต้องรอสำหรับ the status
       ของ the first packet ก่อนดำเนินการต่อ the next frame
Title: Re: STM32F1 ETHERNET
Post by: tha on February 19, 2021, 09:20:55 AM
Retransmission during collision

ในขณะที่ a frame กำลังถูกส่งถ่ายไปยัง the MAC, a collision event อาจเกิดขึ้นบน the MAC line อินเตอร์เฟสใน Half-duplex mode. The MAC จากนั้นจะแสดงให้เห็น a retry พยายามโดยการให้ the status ก่อน the end of frame ถูกรับ. จากนั้น the retransmission ถูกเปิดการใช้งานและ the frame ถูก popped out อีกครั้งจาก the FIFO. หลังจากมากกว่า 96 bytes ถูก popped ไปยัง the MAC core, the FIFO controller ปลดปล่อยพื้นที่นั้นและทำมันให้มีประโยชน์ต่อ the DMA เพื่อใส่ data ให้มากขึ้น. นี้หมายความว่า the retransmission ไม่สามารถทำได้หลังจาก threshold นี้ถูกข้ามหรือเมื่อ the MAC core แสดงให้เห็น a late collision event
Title: Re: STM32F1 ETHERNET
Post by: tha on February 20, 2021, 07:18:53 AM
Transmit FIFO flush operation

The MAC จัดให้มี a control ไปยัง the software เพื่อล้าง the Transmit FIFO ผ่านทางการใช้ของ Bit 20 ใน the Operation mode register. The Flush operation จะเกิดขึ้นทันทีและ the Tx FIFO และ the corresponding pointers ถูกเคลียร์ไปยัง the initial state ถึงแม้ว่า the Tx FIFO จะอยู่ในตรงกลางของการส่งถ่าย a frame ไปยัง the MAC Core. ซึ่งส่งผลให้เกิด an underflow event ใน the MAC transmitter, และ the frame transmission ถูกยกเลิก. The status ของ a frame ดังกล่าวถูกทำเครื่องหมายที่มีทั้ง underflow และ frame flush events (TDES0 bits 13 and 1). ไม่มี data มาถึง the FIFO จาก the application (DMA) ในระหว่าง the Flush operation. Transfer ส่ง status words ถูกส่งถ่ายไปยัง the application สำหรับจำนวนของ frames ที่ถูกล้าง (รวมทั้ง partial frames). Frames ที่ถูกล้างเสร็จสมบูรณ์มี the Frame flush status bit (TDES0 13) เซ็ต. The Flush operation เสร็จสมบูรณ์เมื่อ the application (DMA) ยอมรับทั้งหมดของ the Status words สำหรับ the frames ที่ถูกล้างแล้ว. The Transmit FIFO Flush control register bit จากนั้นถูกเคลียร์. ณ จุดนี้, new frames จาก the application (DMA) ถูกยอมรับ. data ทั้งหมดที่นำเสนอสำหรับ transmission หลังจาก a Flush operation ถูกละทิ้งเว้นแต่พวกมันสตาร์ทด้วย an SOF marker.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 20, 2021, 10:53:40 AM
Transmit status word

ที่ the end of the Ethernet frame ส่งถ่ายไปยัง the MAC core และหลังจาก the core เสร็จสมบูรณ์ the transmission of the frame แล้ว, the transmit status ถูกให้ไปยัง the application. The detailed description of the Transmit Status เป็นอย่างเดียวกับ bits [23:0] ใน TDES0. ถ้า IEEE 1588 time stamping ถูกเปิดการใช้งาน, a specific frames' 64-bit time stamp ถูกส่งคืนกลับ, พร้อมกับ the transmit status.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 21, 2021, 07:26:41 AM
Transmit checksum offload

Communication protocols อย่างเช่น TCP and UDP จัดให้มีใช้ checksum fields, ซึ่งช่วยตรวจสอบความสมบูรณ์ของ data ที่ส่งผ่าน a network. เพราะแพร่หลายมากที่สุดการใช้ของ Ethernet คือเพื่อห่อหุ้ม TCP and UDP ผ่าน IP datagrams, the Ethernet controller มี a transmit checksum offload feature ที่รองรับ checksum calculation และใส่ใน the transmit path, และ error detection ใน the receive path. ส่วนนี้อธิบายการทำงานของ the checksum offload feature สำหรับ transmitted frames.

Note: The checksum สำหรับ TCP, UDP or ICMP ถูกคำนวณบน a complete frame, จากนั้นใส่ลงใน corresponding header
          field ของมัน. เนื่องจากความต้องการนี้, function นี้ถูกเปิดการใช้งานเฉพาะเมื่อ the Transmit FIFO ถูกกำหนดค่าสำหรับ Store-
          and-forward mode (นั่นคือ, เมื่อ the TSF bit ถูกเซ็ตใน the ETH_ETH_DMAOMR register). ถ้า the core ถูกกำหนดค่า
          สำหรับ Threshold (การตัดผ่าน) mode, the Transmit checksum offload จะถูกข้ามผ่าน.

          คุณต้องทำให้แน่ใจว่า the Transmit FIFO มีความลึกเพียงพอเพื่อเก็บ a complete frame ก่อนที่ frame ถูกส่งถ่ายไปยัง the
          MAC Core transmitter. ถ้า the FIFO depth น้อยกว่า the input Ethernet frame size, the payload
          (TCP/UDP/ICMP) checksum insertion function จะถูกข้ามผ่านและเฉพาะ the frame's IPv4 Header checksum ถูก
          แก้ไข, แม้ใน Store-and-forward mode
Title: Re: STM32F1 ETHERNET
Post by: tha on February 22, 2021, 07:23:20 AM
The transmit checksum offload รองรับ two types of checksum calculation และ insertion. checksum นี้สามารถถูกสำหรับแต่ละ frame โดยการเซ็ต the CIC bits (Bits 28:27 ใน TDES1, ที่อธิบายใน TDES1: Transmit descriptor Word1).

ดู IETF specifications RFC 791, RFC 793, RFC 768, RFC 792, RFC 2460 and RFC 4443 สำหรับ IPv4, TCP, UDP, ICMP, IPv6 and ICMPv6 packet header specifications, ตามลำดับ.
•    IP header checksum
      ใน IPv4 datagrams, ความสมบูรณ์ของ the header fields ถูกแสดงให้เห็นโดย the 16-bit header checksum field (ที่สิบเอ็ด
      และที่สิบสอง bytes ของ the IPv4 datagram). The checksum offload ตรวจพบ an IPv4 datagram เมื่อ the Ethernet
      frame's Type field มีค่า 0x0800 และ the IP datagram's Version field มีค่า 0x4. The input frame's checksum field
      ถูกละเว้นในระหว่าง calculation และถูกแทนที่โดย the calculated value. IPv6 headers ไม่มี a checksum field; ดังนั้น, the
      checksum offload ไม่แก้ไข IPv6 header fields. ผลของ this IP header checksum calculation ถูกแสดงให้เห็นโดย the
      IP Header Error status bit ใน the Transmit status (Bit 16). status bit นี้ถูกเซ็ตเมื่อไรก็ตามที่ค่า the Ethernet Type
      field และ the IP header's Version field ไม่มีความสม่ำเสมอ, หรือเมื่อ the Ethernet frame ไม่มี data เพียงพอ, ดังที่แสดงให้
      เห็นโดย the IP header Length field. กล่าวอีกนัยหนึ่ง, บิตนี้ถูกเซ็ตเมื่อ an IP header error ถูกถือสิทธิ์ภายใต้สถานการณ์ต่อไป
      นี้:
      a)    สำหรับ IPv4 datagrams:
      –    The received Ethernet type คือ 0x0800, แต่ the IP header's Version field ไม่เท่ากับ 0x4
      –    The IPv4 Header Length field แสดงให้เห็น a value ที่น้อยกว่า 0x5 (20 bytes)
      –    The total frame length น้อยกว่า the value ที่ให้ไว้ใน the IPv4 Header Length field
      b)    สำหรับ IPv6 datagrams:
      –    The Ethernet type คือ 0x86DD แต่ the IP header Version field ไม่เท่ากับ 0x6
      –    The frame สิ้นสุดก่อน the IPv6 header (40 bytes) หรือ extension header (ดังที่ให้ไว้ใน the corresponding
            Header Length field ใน an extension header) ถูกรับเสร็จสมบูรณ์แล้ว. แม้ว่าเมื่อ the checksum offload ตรวจพบ an
            IP header error ดังกล่าว, มันแทรก an IPv4 header checksum ถ้า the Ethernet Type field แสดงให้เห็น an IPv4
            payload.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 22, 2021, 09:37:32 AM
•    TCP/UDP/ICMP checksum

      The TCP/UDP/ICMP checksum ประมวลผล the IPv4 or IPv6 header (รวมถึง extension headers) และตัดสินว่า the
      encapsulated payload คือ TCP, UDP or ICMP.

      โปรดทราบว่า :
      a)    สำหรับ non-TCP, -UDP, or -ICMP/ICMPv6 payloads, checksum นี้ถูกข้ามผ่านและไม่มีอะไรเพิ่มเติมถูกแก้ไขใน the
              frame.
      b)    Fragmented IP frames (IPv4 or IPv6), IP frames ที่มี security features (อย่างเช่น an authentication header
             หรือ encapsulated security payload), และ IPv6 frames ที่มี routing headers ถูกข้ามผ่านและไม่ถูกประมวลผลโดย
              the checksum.

      The checksum ถูกคำนวณสำหรับ the TCP, UDP, or ICMP payload และใส่ลงในฟิลด์ที่ตรงกันใน the header. Iมันสามารถ
      ทำงานในสองโหมดต่อไปนี้:
      –    ใน the first mode, the TCP, UDP, or ICMPv6 pseudo-header ไม่ถูกรวมไว้ใน the checksum calculation และถูก
            ทึกทักเอาว่ามีอยู่ใน the input frame's checksum field. The checksum field ถูกรวมใน the checksum calculation,
            และจากนั้นถูกแทนที่โดย the final calculated checksum
      –    ใน the second mode, the checksum field ถูกละเว้น, the TCP, UDP, or ICMPv6 pseudo-header data ถูกรวมลงใน
            the checksum calculation, และ the checksum field ถูกเขียนทับด้วย the final calculated value.

      โปรดทราบว่า: for ICMP-over-IPv4 packets, the checksum field ใน the ICMP packet ต้องเป็น 0x0000 เสมอในทั้งสอง
      โหมด, เพราะว่า pseudo-headers ไม่ถูกกำหนดสำหรับ packets ดังกล่าว. ถ้ามันไม่เท่ากับ 0x0000, an incorrect checksum
      อาจถูกใส่ลงใน the packet.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 22, 2021, 10:58:36 AM
   ผลของการทำงานนี้ถูกแสดงให้เห็นโดย the payload checksum error status bit ใน the Transmit Status vector (bit 12).
   The payload checksum error status bit ถูกเซ็ตเมื่ออย่างใดอย่างหนึ่งของต่อไปนี้ถูกตรวจพบ :
   –    the frame ถูกส่งต่อไปยัง the MAC transmitter ใน Store-and-forward mode ไม่มี the end of frame ถูกเขียนไปยัง the
         FIFO
   –    the packet สิ้นสุดก่อนจำนวนของ bytes ที่แสดงให้เห็นโดย the payload length field ใน the IP header ถูกรับ.

   เมื่อ the packet ยาวกว่า the indicated payload length, the bytes ถูกละเว้นเช่น stuff bytes, และไม่มี error ถูกรายงาน. เมื่อ
   the first type of error ถูกตรวจพบ, the TCP, UDP or ICMP header ไม่ถูกแก้ไข. สำหรับ the second error type, ยังคง, the
   calculated checksum ถูกแทรกลงใน the corresponding header field.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 23, 2021, 07:26:33 AM
MII/RMII transmit bit order

แต่ละ nibble (4 บิต) จาก the MII ถูกส่งบน the RMII a dibit (2 บิต) ในแต่ละครั้งโดยลำดับของ dibit transmission ถูกแสดงใน Figure 339. Lower order bits (D1 and D0) ถูกส่งก่อนตามด้วย higher order bits (D2 and D3).

(https://i.imgur.com/oYtaw5a.png)

(https://i.imgur.com/6zN0v5Q.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 23, 2021, 10:38:18 AM
29.5.3 MAC frame reception

The MAC รับ frames ใส่ลงใน the Rx FIFO. The status (ระดับการเติม) ของ FIFO นี้ถูกแสดงให้เห็นไปยัง the DMA ทันทีที่มันข้าม the configured receive threshold (RTC ใน the ETH_DMAOMR register) ดังนั้น the DMA สามารถเริ่มต้น pre-configured burst transfers ไปยัง the AHB interface.

ใน the default Cut-through mode, เมื่อ 64 bytes (กำหนดค่าด้วย the RTC bits ใน the ETH_DMAOMR register) หรือ a full packet of data ถูกรับลงใน the FIFO, the data ถูก popped out และ the DMA ถูกแจ้งให้ทราบการมีให้ใช้ของมัน. ทันทีที่ the DMA เริ่มต้น the transfer ไปยัง the AHB interface, the data ส่งถ่ายอย่างต่อเนื่องจาก the FIFO จนกระทั่ง a complete packet ถูกส่งถ่ายแล้ว. เมื่อ completion of the EOF frame ส่งถ่าย, the status word ถูก popped out และส่งไปยัง the DMA controller.

ใน Rx FIFO Store-and-forward mode (กำหนดค่าโดย the RSF bit ใน the ETH_DMAOMR register), a frame ถูกอ่านเฉพาะหลังจากถูกเขียนลงใน the Receive FIFO เสร็จสมบูรณ์แล้ว. ในโหมดนี้, all error frames ถูก dropped (ถ้า the core ถูกกำหนดค่าให้ทำเช่นนั้น) ดังนั้นเฉพาะ valid frames ถูกอ่านและส่งต่อไปยัง the application. ใน Cut-through mode, some error frames
ไม่ถูก dropped, เพราะว่า the error status ถูกรับที่ the end of the frame, ตามเวลาจุดสตาร์ทของเฟรมนั้นได้ถูกอ่านของ the FIFO แล้ว

A receive operation ถูกเริ่มต้นเมื่อ the MAC ตรวจพบ an SFD บน the MII. The core ปอก the preamble and SFD ก่อนดำเนินการต่อเพื่อประมวลผล the frame. The header fields ถูกเช็คสำหรับ the filtering และ the FCS field ถูกใช้เพื่อตรวจสอบ the CRC สำหรับ the frame. The frame ถูก dropped ใน the core ถ้ามันล้มเหลว the address filter
Title: Re: STM32F1 ETHERNET
Post by: tha on February 24, 2021, 07:36:38 AM
Receive protocol

The received frame preamble and SFD ถูกปอก. ทันทีที่ the SFD ถูกตรวจพบ, the MAC สตาร์ทการส่ง the Ethernet frame data ไปยัง the receive FIFO, เริ่มต้นด้วย the first byte ตามด้วย the SFD (destination address). ถ้า IEEE 1588 time stamping ถูกเปิดการใช้งาน, a snapshot of the system time ถูกจับเมื่อ any frame's SFD ถูกตรวจพบบน the MII. เว้นแต่ the MAC กรองออกและดร็อป the frame, time stamp นี้จะถูกส่งต่อไปยัง the application.

ถ้า the received frame length/type field น้อยกว่า 0x600 และถ้า the MAC ถูกโปรแกรมสำหรับ the auto CRC/ทางเลือกการปอก pad, the MAC ส่ง the data ของ the frame ไปยัง RxFIFO สูงถึง the count ที่ระบุใน the length/type field, จากนั้นสตาร์ทการดร็อป bytes (รวมทั้ง the FCS field). ถ้า the Length/Type field มากกว่าหรือเท่ากับ 0x600, the MAC ส่ง all received Ethernet frame data ไปยัง Rx FIFO, โดยไม่คำนึงถึงค่าบน the programmed auto-CRC strip option. The MAC watchdog timer ถูกเปิดการใช้งานโดยเริ่มต้น, นั่นคือ, frames ที่สูงกว่า 2048 bytes (DA + SA + LT + Data + pad + FCS) จะถูกตัดออก. คุณลักษณะนี้สามารถถูกปิดการใช้งานโดยการโปรแกรม the watchdog disable (WD) bit ใน the MAC configuration register. อย่างไรก็ตาม, ถึงแม้ว่า the watchdog timer ถูกปิดการใช้งาน, frames ที่มีขนาดมากกว่า 16 KB จะถูกตัดออกและ a watchdog timeout status ถูกให้.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 24, 2021, 08:59:47 AM
Receive CRC: automatic CRC and pad stripping

The MAC เช็คสำหรับ any CRC error ใน the receiving frame. มันคำนวณ the 32-bit CRC สำหรับ the received frame ที่รวมถึง the Destination address field ผ่านทาง the FCS field. การเข้ารหัสถูกกำหนดโดยพหุนามต่อไปนี้

          (https://i.imgur.com/3CiA2LR.png)

โดยไม่คำนึงถึง the auto-pad/CRC strip, the MAC รับ the entire frame เพื่อคำนวณ the CRC เช็คสำหรับ the received frame.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 24, 2021, 09:58:17 AM
Receive checksum offload

ทั้ง IPv4 and IPv6 frames ใน the received Ethernet frames ถูกตรวจพบและประมวลผลเพือข้อมูลที่สมบูรณ์. คุณสามารถเปิดการใช้งาน the receive checksum offload โดยการเซ็ต the IPCO bit ใน the ETH_MACCR register. The MAC receiver วินิจฉัย IPv4 or IPv6 frames โดยการเช็คสำหรับค่า 0x0800 หรือ 0x86DD, ตามลำดับ, ใน the received Ethernet frame Type field. การวินิจฉัยนี้ใช้กับ VLAN-tagged frames เช่นกัน. The receive checksum offload คำนวณ IPv4 header checksums และเช็คว่าตรงกับ the received IPv4 header checksums. The IP Header Error bit ถูกเซ็ตสำหรับความไม่ตรงกันใดๆระหว่าง the indicated payload type (Ethernet Type field) และ the IP header version, หรือเมื่อ the received frame ไม่มี bytes เพียงพอ, ตามที่แสดงให้เห็นโดย the IPv4 header's Length field (หรือเมื่อน้อยกว่า 20 bytes มีให้ใช้ใน an IPv4 or IPv6 header). The receive checksum offload ยังวินิจฉัย a TCP, UDP or ICMP payload ใน the received IP datagrams (IPv4 or IPv6) อีกด้วยและคำนวณ the checksum ของ payloads ดังกล่าวอย่างเหมาะสม, ตามที่กำหนดใน the TCP, UDP or ICMP specifications. มันรวม the TCP/UDP/ICMPv6 pseudo-header bytes สำหรับ checksum calculation และเช็คว่า the received checksum field ตรงกับ the calculated value. ผลของการทำงานนี้ถูกให้เป็น a Payload Checksum Error bit ใน the receive status word. status bit นี้ถูกเซ็ตอีกด้วยถ้าความยาวของ the TCP, UDP or ICMP payload ไม่ตรงกับ the expected payload length ที่ให้ใน the IP header.ตามที่กล่าวไว้ใน TCP/UDP/ICMP checksum, the receive checksum offload ข้ามผ่าน the payload of fragmented IP datagrams, IP datagrams ที่มี security features, IPv6 routing headers, และ payloads อื่นที่ไม่ใช่ TCP, UDP or ICMP. ข้อมูลนี้  (ไม่ว่า the checksum ถูกข้ามผ่านหรือไม่ก็ตาม) ถูกให้ใน the receive status, ตามที่อธิบายใน the RDES0: Receive descriptor Word0 section. ในการกำหนดค่านี้, the core ไม่ต่อท้าย any payload checksum bytes ไปยัง the received Ethernet frames.

ตามที่กล่าวไว้ใน RDES0: Receive descriptor Word0, ความหมายของ certain register bits เปลี่ยนแปลงดังแสดงใน Table 214.

(https://i.imgur.com/YNTeQgh.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 25, 2021, 07:27:29 AM
Receive frame controller

ถ้า the RA bit ถูกรีเซ็ตใน the MAC CSR frame filter register, the MAC ดำเนินการ frame filtering ขึ้นอยู่กับ the destination/source address (the application ยังคงต้องการเพื่อดำเนินการระดับอื่นของการกรองถ้ามันตัดสินใจไม่รับ any bad frames อย่าง runt, CRC error frames, etc.). บนการตรวจพบ a filter-fail, the frame ถูกดร็อปและไม่ส่งถ่ายไปยัง the application. เมื่อ the
filtering parameters ถูกเปลี่ยนแบบไดนามิก, และในกรณีของ (DA-SA) filter-fail, ส่วนที่เหลือของ the frame ถูกดร็อปและ the Rx Status Word ถูกอัปเดตทันที (ที่มี zero frame length, CRC error and Runt Error bits เซ็ต), แสดงให้เห็น the filter fail. ใน Ethernet power down mode, all received frames ถูกดร็อป, และไม่ถูกส่งต่อไปยัง the application.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 25, 2021, 07:50:45 AM
Receive flow control

The MAC ตรวจพบ the receiving Pause frame และหยุด the frame transmission เป็นเวลา the delay ที่ระบุภายใน the received Pause frame (เฉพาะใน Full-duplex mode). The Pause frame detection function สามารถถูก enabled หรือ disabled ด้วย the RFCE bit ใน ETH_MACFCR. ทันทีที่ receive flow control ถูก enabled แล้ว, the received frame destination address เริ่มต้นถูกมอนิเตอร์สำหรับการตรงกันใดๆกับ the multicast address ของ the control frame (0x0180 C200 0001). ถ้าการตรงกันถูกตรวจพบ (the destination address of the received frame ตรงกับ the reserved control frame destination address), the MAC จากนั้นตัดสินใจว่าจะส่งถ่ายหรือไม่ส่งถ่าย the received control frame ไปยัง the application, ขึ้นอยู่กับ the level of the PCF bit in ETH_MACFFR.

The MAC ยังถอดรหัส the type, opcode, and Pause Timer fields of the receiving control frame. ถ้า the byte count of the status แสดงให้เห็น 64 bytes, และถ้าไม่มี CRC error, the MAC transmitter หยุด the transmission of any data frame เป็นเวลาในช่วงเวลาของ the decoded Pause time value, คูณด้วย the slot time (64 byte times สำหรับทั้ง 10/100 Mbit/s modes). ในขณะเดียวกัน, ถ้า another Pause frame ถูกตรวจพบที่มี a zero Pause time value, the MAC รีเซ็ต the Pause time และจัดการ new pause request นี้.

ถ้า the received control frame ไม่ตรงกับ the type field (0x8808), the opcode (0x00001), หรือ the byte length (64 bytes), หรือถ้ามี a CRC error, the MAC ไม่สร้าง a Pause.

ในกรณีของ a pause frame ที่มี a multicast destination address, the MAC กรอง the frame ขึ้นอยู่กับ the address match.

สำหรับ a pause frame ที่มี a unicast destination address, the MAC filtering ขึ้นอยู่กับว่า the DA ตรงกับ the contents of the MAC address 0 register และหรือว่า the UPDF bit ใน ETH_MACFCR ถูกเซ็ต (การตรวจพบ a pause frame แม้จะมี a unicast destination address). The PCF register bits (bits [7:6] in ETH_MACFFR) ควบคุมการกรองสำหรับ control frames
นอกเหนือจาก address filtering.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 25, 2021, 09:43:00 AM
Receive operation multiframe handling

เนื่องจาก the status มีให้ใช้ทันทีติดตาม the data, the FIFO มีสามารถของการเก็บ any number of frames ลงในมัน, ตราบเท่าที่มันไม่เต็ม.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 25, 2021, 10:47:49 AM
Error handling

ถ้า the Rx FIFO เต็มก่อนมันรับ the EOF data จาก the MAC, an overflow ถูกประกาศและ the whole frame ถูกดร็อป, และ the overflow counter ใน the (ETH_DMAMFBOCR register) ถูกเพิ่ม. The status แสดงให้เห็น a partial frame เนื่องจาก overflow. The Rx FIFO สามารถกรอง error และ frames ที่มีขนาดเล็ก, ถ้าเปิดการใช้งาน (โดยใช้ the FEF and FUGF bits ใน ETH_DMAOMR)

ถ้า the Receive FIFO ถูกกำหนดค่าให้ทำงานใน Store-and-forward mode, all error frames สามารถถูกกรองและดร็อป.

ใน Cut-through mode, ถ้า a frame's status และ length มีให้ใช้เมื่อ frame's SOF นั้นถูกอ่านจาก the Rx FIFO, จากนั้น the complete erroneous frame สามารถถูกดร็อป. The DMA สามารถล้าง the error frame ที่ถูกอ่านจาก the FIFO, โดยการเปิดการใช้งาน the receive frame flash bit. The data ส่งถ่ายไปยัง the application (DMA) จะถูกหยุดและส่วนที่เหลือของ the frame ถูกอ่านภายในและถูกดร็อป. The next frame transfer จะสามารถถูกสตาร์ท, ถ้ามีให้ใช้ประโยชน์.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 25, 2021, 11:02:04 AM
Receive status word

ที่ the end of the Ethernet frame reception, the MAC ส่งออก the receive status ไปยัง the application (DMA). รายละเอียดคำอธิบายของ the receive status เป็นอย่างเดียวกับสำหรับ bits[31:0] ใน RDES0, ถูกให้ไว้ใน RDES0: Receive descriptor Word0.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 25, 2021, 11:33:36 AM
Frame length interface

ในกรณีของ switch applications, data transmission และ reception ระหว่าง the application และ MAC เกิดขึ้นอย่าง complete frame transfers. The application layer ควรทราบถึงความยาวของ the frames ที่ได้รับจาก the ingress port เพื่อส่งถ่าย the frame ไปยัง the egress port. The MAC core จัดให้มี the frame length ของแต่ละ received frame ภายใน the status ที่จุดสิ้นสุดของแต่ละ frame reception.

Note: A frame length value เป็น 0 ถูกให้สำหรับ partial frames ที่เขียนลงใน the Rx FIFO เนื่องจาก overflow
Title: Re: STM32F1 ETHERNET
Post by: tha on February 25, 2021, 11:44:24 AM
MII/RMII receive bit order

แต่ละ nibble(4 บิต) ถูกส่งไปยัง the MII จาก the dibit (2 บิต) ที่รับจาก the RMII ใน the nibble transmission order แสดงใน Figure 343. The lower-order bits (D0 and D1) ถูกรับก่อน, ตามด้วย the higher-order bits (D2 and D3).

(https://i.imgur.com/SdGiOOJ.png)

(https://i.imgur.com/LnjpeZo.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 26, 2021, 06:41:14 AM
29.5.4 MAC interrupts

Interrupts สามารถถูกสร้างขึ้นจาก the MAC core อันเป็นผลมาจาก various events.

The ETH_MACSR register อธิบาย the events ที่สามารถเป็นเหตุให้เกิด an interrupt จาก the MAC core. คุณสามารถป้องกันแต่ละ event จากการถือสิทธิ์ the interrupt โดยการเซ็ต the corresponding mask bits ใน the Interrupt Mask register.

The interrupt register bits แสดงให้เห็นเฉพาะ the block จากที่ the event ถูกรายงาน. คุณต้องอ่าน the corresponding status registers และ registers อื่นๆเพื่อเคลียร์ the interrupt. ตัวอย่างเช่น, bit 3 ของ the Interrupt register, set high, แสดงให้เห็นว่า the Magic packet หรือ Wake-on-LAN frame ถูกรับใน Power-down mode. คุณต้องอ่าน the ETH_MACPMTCSR Register เพื่อเคลียร์ interrupt event นี้.

(https://i.imgur.com/AdnleMd.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 26, 2021, 08:29:16 AM
29.5.5 MAC filtering

Address filtering

Address filtering เช็ค the destination and source addresses บน all received frames และ the address filtering status ถูกรายงานสอดคล้องกัน. Address checking ขึ้นอยู่กับ different parameters (Frame filter register) ที่เลือกโดย the application. The filtered frame ยังสามารถถูกแยกแยะ : multicast หรือ broadcast frame.

Address filtering ใช้ the station's physical (MAC) address และ the Multicast Hash table สำหรับ address checking purposes.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 26, 2021, 10:00:44 AM
Unicast destination address filter

The MAC รองรับสูงถึง 4 MAC addresses สำหรับ unicast perfect filtering. ถ้า perfect filtering ถูกเลือก (HU bit ใน the Frame filter register ถูกรีเซ็ต), the MAC เปรียบเทียบ all 48 bits ของ the received unicast address กับ the programmed MAC address เพื่อความตรงกันใดๆ. Default MacAddr0 ถูกเปิดการใช้งานเสมอ, other addresses MacAddr1–MacAddr3 ถูกเลือกด้วย an individual enable bit. แต่ละ byte of these other addresses (MacAddr1–MacAddr3) สามารถถูกบังในระหว่าง comparison กับ the corresponding received DA byte โดยการเซ็ต the corresponding Mask Byte Control bit ใน the register. สิ่งนี้ช่วย group address filtering สำหรับ the DA. ใน Hash filtering mode (เมื่อ HU bit ถูกเซ็ต), the MAC ดำเนินการ imperfect filtering สำหรับ unicast addresses โดย a 64-bit Hash table. สำหรับ hash filtering, the MAC ใช้ the 6 upper CRC (ดู note 1 ข้างล่าง) bits ของ the received destination address เพื่อเป็นตัวชี้สิ่งที่อยู่ภายในของ the Hash table. ค่า 000000 เลือก bit 0 ใน the selected register, และค่า 111111 เลือก bit 63 ใน the Hash Table register. ถ้า the corresponding bit (ที่แสดงให้เห็นโดย the 6-bit CRC) ถูกเซ็ตเป็น 1, the unicast frame กล่าวได้ว่าผ่าน the Hash filter; มิฉะนั้น, the frame ล้มเหลว the Hash filter.

Note: CRC นี้คือ a 32-bit value เข้ารหัสโดยพหุนามต่อไปนี้ (สำหรับรายละเอียดเพิ่มเติมโปรดดูที่ Section 29.5.3):

              (https://i.imgur.com/NVhBIhZ.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 26, 2021, 11:06:10 AM
Multicast destination address filter

The MAC สามารถถูกโปรแกรมเพื่อผ่าน all multicast frames โดยการเซ็ต the PAM bit ใน the Frame filter register. ถ้า the PAM bit ถูกรีเซ็ต, the MAC ดำเนินการ the filtering สำหรับ multicast addresses ขึ้นอยู่กับ the HM bit ใน the Frame filter register. ใน Perfect filtering mode, the multicast address ถูกเปรียบเทียบกับ the programmed MAC destination address registers (1–3). Group address filtering ยังถูกรองรับอีกด้วย. ใน Hash filtering mode, the MAC ดำเนินการ imperfect filtering โดยใช้ a 64-bit Hash table. สำหรับ hash filtering, the MAC ใช้ the 6 upper CRC (ดู note 1 ข้างล่าง) bits ของ the received multicast address เพื่อเป็นตัวชี้สิ่งที่อยู่ภายในของ the Hash table. ค่า 000000 เลือก bit 0 ใน the selected register, และค่า 111111 เลือก bit 63 ใน the Hash Table register. ถ้า the corresponding bit ถูกเซ็ตเป็น 1, จากนั้น the multicast frame กล่าวได้ว่าผ่าน the Hash filter; มิฉะนั้น, the frame ล้มเหลว the Hash filter.

Note: CRC นี้คือ a 32-bit value เข้ารหัสโดยพหุนามต่อไปนี้ (สำหรับรายละเอียดเพิ่มเติมโปรดดูที่ Section 29.5.3):

             (https://i.imgur.com/NVhBIhZ.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 27, 2021, 07:15:09 AM
Hash or perfect address filter

The DA filter สามารถถูกกำหนดค่าเพื่อส่งผ่าน a frame เมื่อ DA ของมันตรงกับอย่างใดอย่างหนึ่ง the Hash filter หรือ the Perfect filter โดยการเซ็ต the HPF bit ใน the Frame filter register และการเซ็ต the corresponding HU หรือ HM bits. การกำหนดค่านี้ใช้กับทั้ง unicast และ multicast frames. ถ้า the HPF bit ถูกรีเซ็ต, เฉพาะหนึ่ง the filters (Hash or Perfect) เท่านั้นที่ถูกใช้กับ the received frame.

Broadcast address filter

The MAC ไม่กรอง any broadcast frames ใน the default mode. อย่างไรก็ตาม, ถ้า the MAC ถูกโปรแกรมเพื่อโละทิ้ง all broadcast frames โดยการเซ็ต the BFD bit ใน the Frame filter register, any broadcast frames จะถูกดร็อป.

Unicast source address filter

The MAC สามารถดำเนินการ perfect filtering ได้อีกด้วยขึ้นอยู่กับ the source address field ของ the received frames. โดยค่าเริ่มต้น, the MAC เปรียบเทียบ the SA field กับค่าที่ถูกโปรแกรมใน the SA registers. The MAC address registers [1:3] สามารถถูกกำหนดค่าเพื่อบรรจุ SA แทนที่ DA สำหรับ comparison, โดยการเซ็ต bit 30 ใน the corresponding register. Group filtering with SA ถูกรองรับด้วย. The frames ที่ล้มเหลว the SA filter จะถูกดร็อปโดย the MAC ถ้า the SAF bit ใน the Frame filter register ถูกเซ็ต. มิฉะนั้น, ผลของ the SA filter จะถูกให้เป็น a status bit ใน the Receive Status word (ดู RDES0: Receive descriptor Word0).

เมื่อ the SAF bit ถูกเซ็ต, ผลลัพธ์ของ the SA and DA filters ถูก AND เพื่อตัดสินว่า the frame ต้องการที่จะถูกส่งต่อ. ซึ่งหมายความว่าอย่างใดอย่างหนึ่งของ the filter fail result จะดร็อป the frame. ทั้งสอง filters ต้องส่งผ่าน the frame เพื่อ the frame จะถูกส่งต่อไปยัง the application.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 27, 2021, 09:18:15 AM
Inverse filtering operation

สำหรับทั้ง destination and source address filtering, มีทางเลือกเพื่อกลับ the filter-match result ที่ the final output. พวกมันถูกควบคุมโดย the DAIF and SAIF bits ใน the Frame filter register, ตามลำดับ. The DAIF bit ใช้ได้สำหรับทั้ง Unicast and Multicast DA frames. ผลลัพธ์ของ the unicast/multicast destination address filter ถูกกลับในโหมดนี้. ในทำนองเดียวกัน, เมื่อ the SAIF bit ถูกเซ็ต, ผลลัพธ์ของ the unicast SA filter ถูกกลับ. Table 215 and Table 216 สรุป destination and source address filtering ขึ้นอยู่กับประเภทของ frame ที่รับ.

(https://i.imgur.com/hQdO8lj.png)

(https://i.imgur.com/zs4596g.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on February 28, 2021, 07:06:14 AM
29.5.6 MAC loopback mode

The MAC รองรับ loopback ของ transmitted frames ไปยัง receiver ของมัน. โดยค่าเริ่มต้น, the MAC loopback function ถูกปิดการใช้งาน, แต่คุณลักษณะนี้สามารถถูกเปิดการใช้งานโดยการโปรแกรม the Loopback bit ใน the MAC ETH_MACCR register.

29.5.7 MAC management counters: MMC

The MAC management counters (MMC) เก็บรักษาชุดของ registers สำหรับการรวบรวมสถิติบน the received and transmitted frames ซึ่งรวมถึง a control register สำหรับการควบคุมพฤติกรรมของ the registers, two 32-bit registers บรรจุ generated interrupts (receive and transmit), และ two 32-bit registers บรรจุ masks for the Interrupt register (receive and transmit). registers เหล่านี้สามารถเข้าถึงจาก the application. แต่ละ register มีความกว้าง 32 bits.

Section 29.8 อธิบาย the various counters และแสดงรายการ the addresses ของแต่ละของ the statistics counters. address นี้ถูกใช้สำหรับอ่าน/เขียนเข้าถึงไปยัง the desired transmit/receive counter.

The Receive MMC counters ถูกอัปเดตสำหรับ frames ที่ผ่าน address filtering. ดร็อป frames statistics ที่ไม่ถูกอัปเดตเว้นแต่ the dropped frames เป็น runt frames ที่น้อยกว่า 6 bytes (DA bytes ไม่ได้ถูกรับอย่างครบถ้วน).

Good transmitted and received frames

Transmitted frames ถูกพิจารณาว่า "ดี" ถ้าส่งสำเร็จลง. กล่าวอีกนัยหนึ่ง, a transmitted frame จะดีถ้า the frame transmission ไม่ถูกยกเลิกเนื่องจาก errors ใดๆต่อไปนี้ :
   + Jabber Timeout
   + No Carrier/Loss of Carrier
   + Late Collision
   + Frame Underflow
   + Excessive Deferral
   + Excessive Collision

Received frames ถูกพิจารณาว่า "ดี" ถ้าไม่มี errors ต่อไปนี้อยู่:
   + CRC error
   + Runt Frame (shorter than 64 bytes)
   + Alignment error (in 10/ 100 Mbit/s only)
   + Length error (non-Type frames only)
   + Out of Range (non-Type frames only, longer than maximum size)
   + MII_RXER Input error

The maximum frame size ขึ้นอยู่กับ the frame type, ดังต่อไปนี้:
   + Untagged frame maxsize = 1518
   + VLAN Frame maxsize = 1522
Title: Re: STM32F1 ETHERNET
Post by: tha on February 28, 2021, 01:49:42 PM
29.5.8 Power management: PMT

section นี้อธิบาย the power management (PMT) mechanisms รองรับโดย the MAC. PMT รองรับ the reception ของ network (remote) wakeup frames และ Magic Packet frames. PMT สร้าง interrupts สำหรับ wakeup frames และ Magic Packets ที่รับโดย the MAC. The PMT block ถูกเปิดการใช้งานด้วย remote wakeup frame enable และ Magic Packet enable. enable bits (WFE and MPE) เหล่านี้อยู่ใน the ETH_MACPMTCSR register และถูกโปรแกรมโดย the application. เมื่อ the power down mode ถูกเปิดการใช้งานใน the PMT, จากนั้น all received frames ถูกดร็อปโดย the MAC และพวกมันไม่ถูกส่งต่อไปยัง the application. The MAC ออกมาจาก the power down mode เฉพาะเมื่ออย่างใดอย่างหนึ่ง a Magic Packet หรือ a Remote wakeup frame ถูกรับและ the corresponding detection ถูกเปิดการใช้งาน.
Title: Re: STM32F1 ETHERNET
Post by: tha on February 28, 2021, 03:56:07 PM
Remote wakeup frame filter register

มี 8  wakeup frame filter registers. เพื่อเขียนบนแต่ละของรีจีสเตอร์, โหลด the wakeup frame filter register value ตามค่า. ค่าที่ต้องการของ the wakeup frame filter ถูกโหลดโดยการโหลดตามลำดับแปดครั้งของ the wakeup frame filter register. The read operation เหมือนกันกับ the write operation. เพื่ออ่านแปดค่า, คุณต้องอ่านแปดครั้ง the wakeup frame filter register เพื่อให้ถึง the last register. แต่ละ read/write ชี้ the wakeup frame filter register ไปยัง the next filter register.

(https://i.imgur.com/0hw3V5P.png)

• Filter i Byte Mask

register นี้กำหนดซึ่ง bytes ของ the frame ถูกตรวจสอบโดย filter i (0, 1, 2, and 3) เพื่อตัดสินว่า the frame เป็นหรือไม่เป็น a wakeup frame. The The MSB (thirty-first bit) ต้องเป็นศูนย์. Bit j [30:0] เป็น the Byte Mask. ถ้า bit j (byte number) ของ the Byte Mask ถูกเซ็ต, ดังนั้น Filter i Offset + j ของ the incoming frame ถูกประมวลผลโดย the CRC block; มิฉะนั้น Filter i Offset + j ถูกละเว้น.

• Filter i Command

4-bit command นี้ควบคุม the filter i operation. Bit 3 ระบุ the address type, กำหนด the pattern's destination address type. เมื่อ the bit นี้ถูกเซ็ต, the pattern ใช้ได้กับเฉพาะ multicast frames. เมื่อ the bit นี้ถูกรีเซ็ต, the pattern ใช้ได้กับเฉพาะ unicast frames. Bit 2 and bit 1 ถูกสงวนไว้. Bit 0 เป็น the enable bit สำหรับ filter i; ถ้า bit 0 ไม่ถูกเซ็ต, filter i ถูกปิดการใช้งาน.

• Filter i Offset

register นี้กำหนด the offset (ระยะที่เพิ่มไป) (ภายใน the frame) จากซึ่ง the frames ถูกตรวจสอบโดย filter i. 8-bit pattern offset นี้คือ the offset สำหรับ the filter i byte แรกที่จะถูกตรวจสอบ. ต่ำสุดที่ยอมได้คือ 12, ซึ่งหมายถึง the 13th byte ของ the frame (offset value 0 หมายถึง the first byte of the frame).

• Filter i CRC-16

register นี้บรรจุ the CRC_16 value ที่คำนวณจาก the pattern, เช่นเดียวกับ the byte mask ถูกโปรแกรมไว้ที่ the wakeup filter register block.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 01, 2021, 07:13:41 AM
Remote wakeup frame detection

เมื่อ the MAC อยู่ใน sleep mode และ the remote wakeup bit ถูกเปิดการใช้งานใน the ETH_MACPMTCSR register, normal operation ถูกกลับคืนใหม่หลังจากการรับ a remote wakeup frame. The application เขียน all eight wakeup filter registers, โดยการดำเนินการเขียนตามลำดับไปยัง the wakeup frame filter register address. The application เปิดการใช้งาน remote wakeup โดยการเขียน a 1 ไปยัง bit 2 ใน the ETH_MACPMTCSR register. PMT รองรับ four programmable filters ที่จัดให้มี different receive frame patterns. ถ้า the incoming frame ผ่าน the address filtering ของ Filter Command, และถ้า Filter CRC-16 ตรงกับ the incoming examined pattern, จากนั้น the wakeup frame จะถูกรับ. Filter_offset (ค่าต่ำสุด 12, ซึ่งหมายถึงลำดับที่ the 13th byte of the frame) กำหนด the offset จากซึ่ง the frame ที่จะถูกตรวจสอบ. Filter Byte Mask กำหนดซึ่ง bytes ของ the frame ต้องถูกตรวจสอบ. The thirty-first bit ของ Byte Mask ต้องถูกเซ็ตเป็นศูนย์. The wakeup frame ถูกเช็คเฉพาะสำหรับ length error, FCS error, dribble bit error, MII error, collision, และเพื่อให้แน่ใจว่ามันไม่ใช่ a runt frame. แม้ว่า the wakeup frame มีความยาวมากว่า 512 bytes, ถ้า the frame มี a valid CRC value, มันจะถูกพิจารณาว่าใช้ได้. Wakeup frame detection ถูกอัปเดตใน the ETH_MACPMTCSR register สำหรับทุกๆ remote wakeup frame ที่ถูกรับ. ถ้าเปิดการใช้งาน, a PMT interrupt จะถูกสร้างเพื่อแสดงให้เห็น the reception of a remote wakeup frame.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 01, 2021, 09:44:17 AM
Magic packet detection

The Magic Packet frame อยู่บนฐานของวิธีการที่ใช้ Advanced Micro Device's Magic Packet technology เพื่อเปิดเครื่อง the sleeping device บน the network. The MAC รับ a specific packet ของ information, ที่เรียกว่า a Magic Packet, ส่งไปยัง the node บน the network. เฉพาะ Magic Packets ที่ถูกส่งไปยัง the device หรือ a broadcast address ถูกเช็คเพื่อตัดสินว่าพวกมันตรงตาม the wakeup requirements. Magic Packets ที่ผ่าน address filtering (unicast หรือ broadcast) ถูกเช็คเพื่อตัดสินว่าพวกมันตรงตาม the remote Wake-on-LAN data format ขนาด 6 bytes ของทั้งหมดตามด้วย a MAC address ที่ปรากฎขึ้น 16 ครั้ง. The application เปิดการใช้งาน Magic Packet wakeup โดยการเขียน a 1 ไปยัง bit 1 ใน the ETH_MACPMTCSR register. The PMT block จะมอนิเตอร์อย่างสม่ำเสมอแต่ละ frame ที่ส่งไปยัง the node สำหรับ a specific Magic Packet pattern. แต่ละ received frame ถูกเช็คสำหรับ a 0xFFFF FFFF FFFF pattern ติดตาม the destination and source address field. The PMT block จากนั้นเช็ค the frame สำหรับการทำซ้ำ 16 ครั้งของ the MAC address โดยไม่มี any breaks หรือ interruptions. ในกรณีของการหยุดใน the 16 repetitions of the address, the 0xFFFF FFFF FFFF pattern ถูกสแกนสำหรับอีกครั้งใน the incoming frame. The 16 repetitions สามารถอยู่ที่ไหนก็ได้ใน the frame, แต่ต้องถูกนำหน้าด้วย the synchronization stream (0xFFFF FFFF FFFF). The device ยังยอมรับ a multicast frame อีกด้วย, ตราบเท่าที่ the 16 duplications of the MAC address ถูกตรวจพบ. ถ้า the MAC address ของ a node คือ 0x0011 2233 4455, จากนั้น the MAC จะสแกนสำหรับ the data sequence:

     Destination address source address .................... FFFF FFFF FFFF
     0011 2233 4455 0011 2233 4455 0011 2233 4455 0011 2233 4455
     0011 2233 4455 0011 2233 4455 0011 2233 4455 0011 2233 4455
     0011 2233 4455 0011 2233 4455 0011 2233 4455 0011 2233 4455
     0011 2233 4455 0011 2233 4455 0011 2233 4455 0011 2233 4455
     ...CRC

Magic Packet detection ถูกอัปเดตใน the ETH_MACPMTCSR register สำหรับ Magic Packet ที่ได้รับ. ถ้า enabled, a PMT interrupt ถูกสร้างขึ้นเพื่อแสดงให้เห็น the reception of a Magic Packet.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 01, 2021, 11:37:55 AM
System consideration during power-down

The Ethernet PMT block สามารถตรวจจับ frames ในขณะที่ the system อยู่ใน the Stop mode, โดยมีเงื่อนไขว่า the EXTI line 19 ถูกเปิดการใช้งาน.

The MAC receiver state machine ควรยังคงเปิดการใช้งานอยู่ในระหว่าง the power-down mode. นี้หมายความว่า the RE bit ต้องยังคงเซ็ตใน the ETH_MACCR register เนื่องจากมันมีส่วนเกี่ยวข้องใน magic packet/ wake-on-LAN frame detection. The transmit state machine อย่างไรก็ตามควรถูกปิดในระหว่าง the power-down mode โดยการเคลียร์ the TE bit ใน the ETH_MACCR register. นอกจากนี้, the Ethernet DMA ควรถูกปิดการใช้งานในระหว่าง the power-down mode, เนื่องจากมันไม่จำเป็นต้องคัดลอก the magic packet/wake-on-LAN frame ลงใน the SRAM. เพื่อปิดการใช้งาน the Ethernet DMA, เคลียร์ the ST bit และ the SR bit (สำหรับ the transmit DMA และ the receive DMA, ตามลำดับ) ใน the ETH_DMAOMR register

The recommended power-down and wakeup sequences เป็นดังต่อไปนี้:
1.    ปิดการใช้งาน the transmit DMA และคอยสำหรับ any previous frame transmissions เสร็จสมบูรณ์. transmissions เหล่านี้
       สามารถถูกตรวจพบเมื่อ the transmit interrupt ETH_DMASR register[0] ถูกรับ
2.    ปิดการใช้งาน the MAC transmitter และ MAC receiver โดยการเคลียร์ the RE และ TE bits ใน the ETH_MACCR
       configuration register.
3.    คอยสำหรับ the receive DMA ทำการล้าง the frames ทั้งหมดใน the Rx FIFO
4.    ปิดการใช้งาน the receive DMA.
5.    กำหนดค่าและเปิดการใช้งาน the EXTI line 19 เพื่อสร้างอย่างใดอย่างหนึ่ง an event หรือ an interrupt.
6.    ถ้าคุณกำหนดค่า the EXTI line 19 เพื่อสร้าง an interrupt, คุณต้องกำหนดค่า the ETH_WKUP_IRQ Handler function อย่าง
       ถูกต้องอีกด้วย, ซึ่งควรจะเคลียร์ the pending bit ของ the EXTI line 19.
7.    เปิดการใช้งาน Magic packet/Wake-on-LAN frame detection โดยการเซ็ต the MFE/ WFE bit ใน the
       ETH_MACPMTCSR register.
8.    เปิดการใช้งาน the MAC power-down mode, โดยการเซ็ต the PD bit ใน the ETH_MACPMTCSR register.
9.    เปิดการใช้งาน the MAC Receiver โดยการเซ็ต the RE bit ใน the ETH_MACCR register.
10.  เข้าสู่ the system's Stop mode (สำหรับรายละเอียดที่มากขึ้นอ้างอิงถึง Section 5.3.4: Stop mode):
11.  ในการรับ a valid wakeup frame, the Ethernet peripheral ออกจาก the power-down mode.
12.  อ่าน the ETH_MACPMTCSR เพื่อเคลียร์ the power management event flag, เปิดการใช้งาน the MAC transmitter state
       machine, และ the receive และ transmit DMA.
13.  กำหนดค่า the system clock: เปิดการใช้งาน the HSE และเซ็ต the clocks.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 02, 2021, 07:30:11 AM
29.5.9 Precision time protocol (IEEE1588 PTP)

The IEEE 1588 standard กำหนด a protocol ที่ยอมให้มี precise clock synchronization ใน measurement and control systems จัดให้มีใช้ด้วยเทคโนโลยีอย่างเช่น network communication, local computing and distributed objects. The protocol ใช้กับ systems ที่สื่อสารโดย local area networks ที่รองรับ multicast messaging, รวมถึง (แต่ไม่จำกัดถึง) Ethernet. protocol นี้ถูกใช้เพื่อซิงโครไนส์ heterogeneous systems ที่รวมถึง clocks ที่มีความแม่นยำประจำตัว, ความละเอียดและความมีเสถียรที่แตกต่างกันไป. The protocol รองรับ system-wide synchronization ความเที่ยงตรงใน the submicrosecond range ด้วย network and local clock computing resources ที่ต่ำ. The message-based protocol, รู้กันในนาม the precision time protocol (PTP), ถูกขนส่งผ่าน UDP/IP. The system หรือ network ถูกแบ่งประเภทออกเป็น Master และ Slave nodes เพื่อกระจาย the timing/clock information. The protocol's technique สำหรับการซิงโครไนส์ a slave node กับ a master node โดยการแลกเปลี่ยน PTP messages ถูกอธิบายใน Figure 349.

(https://i.imgur.com/T95Qkop.png)

1.    The master ออกอากาศ PTP Sync messages ไปยัง nodes ทั้งหมดของมัน. The Sync message บรรจุ the master's
       reference time information. เวลาที่ message นี้ออกจาก the master's system คือ t1. สำหรับ Ethernet ports, เวลานี้จะ
       ต้องถูกจับที่ the MII.
2.    A slave รับ the Sync message และจับ the exact time, t2 ด้วย, โดยใช้ timing reference ของมัน
3.    The master จากนั้นส่ง the slave ด้วย a Follow_up message, ซึ่งบรรจุ the t1 information สำหรับใช้ในภายหลัง.
4.    The slave ส่ง the master ด้วย a Delay_Req message, สังเกตุ the exact time, t3, ที่ frame นี้ออกจาก the MII.
5.    The master รับ message นี้และจับ the exact time, t4, ที่มันเข้าสู่ system ของมัน.
6.    The master ส่ง the t4 information ไปยัง the slave ใน the Delay_Resp message.
7.    The slave ใช้สี่ค่าของ t1, t2, t3, and t4 เพื่อซิงโครไนส์ local timing reference ของมันกับ the master's timing
       reference.

ส่วนใหญ่ของ the protocol implementation เกิดขึ้นใน the software, เหนือ the UDP layer. ดังอธิบายข้างบน, อย่างไรก็ตาม, hardware support ถูกต้องการเพื่อจับ the exact time เมื่อ specific PTP packets เข้าสู่หรือออกจาก the Ethernet port ที่ the MII. timing information นี้ต้องถูกจับและส่งคืนกลับไปยัง the software สำหรับ a proper, high-accuracy implementation of PTP.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 02, 2021, 10:14:24 AM
Reference timing source

เพื่อให้ได้ a snapshot ของ the time, the core ต้องการ a reference time ใน 64-bit format (แยกลงใน two 32-bit channels, ที่มี the upper 32 bits จัดให้มี time ใน seconds, และ the lower 32 bits แสดงให้เห็น time ใน nanoseconds) ดังกำหนดใน the IEEE 1588 specification.

The PTP reference clock input ถูกใช้เพือสร้างภายใน the reference time (ถูกเรียกว่า the System Time อีกด้วย) และเพื่อจับ time stamps. The frequency ของ reference clock นี้ต้องมากกว่าหรือเท่ากับความละเอียดของ time stamp counter. The synchronization accuracy target ระหว่าง the master node และ the slaves อยู่ประมาณ 100 ns.

The generation, update และ modification ของ the System Time ถูกอธิบายใน System Time correction methods.

The accuracy ขึ้นอยู่กับ the PTP reference clock input period, the characteristics of the oscillator (drift) และ the frequency of the synchronization procedure.

เนื่องจาก the synchronization จาก the Tx and Rx clock input domain ไปยัง the PTP reference clock domain, ความไม่แน่นอนบน the time stamp latched value คือ 1 reference clock period. ถ้าเรารวมความไม่แน่นอนเนื่องจาก resolution, เราจะรวมครึ่งหนึ่ง the period สำหรับ time stamping.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 03, 2021, 07:10:03 AM
Transmission of frames with the PTP feature

เมื่อ a frame's SFD ถูกส่งออกบน the MII, a time stamp ถูกจับ. Frames ซึ่ง time stamp capture ถูกต้องการสามารถควบคุมได้บน a per-frame basis. กล่าวอีกนัยหนึ่ง, แต่ละ transmitted frame สามารถถูกทำเครื่องหมายเพื่อแสดงให้เห็นว่า a time stamp ต้องถูกจับหรือไม่สำหรับ frame นั้น. The transmitted frames ไม่ถูกประมวลผลเพื่อวินิจฉัย PTP frames. Frame control ถูกเอาออกใช้ผ่านทาง the control bits ใน the transmit descriptor. Captured time stamps จะถูกส่งกลับไปยัง the application ในลักษณะเดียวกันกับ the status ที่ถูกจัดให้มีสำหรับ frames. The time stamp ถูกส่งกลับพร้อมด้วย the Transmit status ของ the frame, ภายใน the corresponding transmit descriptor, จึงเชื่อมต่อ the time stamp โดยอัตโนมัติไปยัง the specific PTP frame. The 64-bit time stamp information ถูกเขียนกลับไปยัง the TDES2 and TDES3 fields, โดยที่ TDES2 ครอบครอง the time stamp's 32 least significant bits.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 03, 2021, 09:24:44 AM
Reception of frames with the PTP feature

เมื่อ the IEEE 1588 time stamping feature ถูกเปิดการใช้งาน, the Ethernet MAC จับ the time stamp ของทุก frames ที่รับบน the MII. The MAC จัดให้มี the time stamp ทันทีที่ the frame reception เสร็จสมบูรณ์. Captured time stamps ถูกส่งคืนกลับไปยัง the application ในลักษณะเดียวกันกับ the frame status ถูกจัดให้มี. The time stamp ถูกส่งกลับพร้อมด้วย the Receive status ของ the frame, ภายใน the corresponding receive descriptor. The 64-bit time stamp information ถูกเขียนกลับไปยัง the RDES2 and RDES3 fields, โดยที่ RDES2 ครอบครอง the time stamp's 32 least significant bits.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 04, 2021, 07:29:59 AM
System Time correction methods

The 64-bit PTP time ถูกอัปเดตโดยใช้ the PTP input reference clock, HCLK. PTP time นี้ถูกใช้เป็น a source เพื่อจับ snapshots (time stamps) ของ the Ethernet frames ที่กำลังถูกส่งหรือถูกรับที่ the MII. The System Time counter สามารถถูกเริ่มต้นหรือทำให้ถูกต้องโดยใช้อย่างใดอย่างหนึ่ง the Coarse หรือ the Fine correction method.

ใน the Coarse correction method, the initial value หรือ the offset value ถูกเขียนไปยัง the Time stamp update register (อ้างอิงถึง Section 29.8.3). สำหรับการเริ่มต้น, the System Time counter ถูกเขียนด้วยค่าใน the Time stamp update registers, ในขณะที่ system time correction, the offset value (Time stamp update register) ถูกเพิ่มหรือลบออกจาก the system time

ใน the Fine correction method, the slave clock (reference clock) frequency จะลอยไปโดยเคารพต่อ the master clock (ดังกำหนดใน IEEE 1588) ถูกทำให้ถูกต้องในช่วงเวลาหนึ่ง, ไม่เหมือนใน the Coarse correction method ที่มันถูกทำให้ถูกต้องใน a single clock cycle. The longer correction time ช่วยรักษา linear time และไม่ทำให้เกิดการเปลี่ยนแปลงที่รุนแรง (หรือ a large jitter) ใน the reference time ระหว่าง PTP Sync message intervals. ในวิธีนี้, an accumulator สรุปผล the contents of the Addend register ดังแสดงใน Figure 350. The arithmetic carry ที่ the accumulator generates ถูกใช้เป็น a pulse เพื่อเพิ่ม the system time counter.

The accumulator และ the addend เป็น 32-bit registers. ที่นี่, the accumulator ทำหน้าที่เป็น a highprecision frequency multiplier หรือ divider. Figure 350 แสดง algorithm นี้.

(https://i.imgur.com/g2vGkJt.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on March 04, 2021, 10:08:51 AM
The system time update logic ต้องการ a 50 MHz clock frequency เพื่อให้ได้ความแม่นยำ 20 ns. The frequency division ของ the ratio of the reference clock frequency กับ the required clock frequency. ดังนั้น, ถ้า the reference clock (HCLK) คือ, ให้เราพูด, 66 MHz, the ratio ถูกคำนวณเป็น 66 MHz/50 MHz = 1.32. ดังนั้น, the default addend value ที่จะถูกเซ็ตใน the register คือ 2^32/1.32, ซึ่งเท่ากับ 0xC1F0 7C1F.

ถ้า the reference clock ลอยไปต่ำลง, ตัวอย่างเช่นเป็น 65 MHz , อัตราส่วนคือ 65/50 หรือ 1.3 และค่าที่จะเซ็ตใน the addend register คือ 2^32/1.30 เท่ากับ 0xC4EC 4EC4. ถ้า the clock ลอยไปสูงขึ้น, ตัวอย่างเช่นเป็น 67 MHz, the addend register ต้องถูกเซ็ตเป็น 0xBF0 B7672. เมื่อ the clock drift เป็นศูนย์, the default addend value of 0xC1F0 7C1F (2^32/1.32) ควรถูกโปรแกรม.

ใน Figure 350, ค่าคงที่ที่ใช้เพิ่ม the subsecond register คือ 0d43. นี้ทำให้ความแม่นยำ 20 ns ใน the system time (กล่าวอีกนัยหนึ่งมันถูกเพิ่มขึ้น 20 ns ต่อขั้น).

The software ต้องคำนวณ the drift ใน frequency ขึ้นอยูกับ the Sync messages, และเพื่ออัปเดต the Addend register ให้สอดคล้องกัน. ใขั้นต้น, the slave clock ถูกเซ็ตด้วย FreqCompensationValue0 ใน the Addend register. ค่านี้เป็นดังต่อไปนี้:

            FreqCompensationValue0 = 2^32 / FreqDivisionRatio
Title: Re: STM32F1 ETHERNET
Post by: tha on March 05, 2021, 07:03:50 AM
ถ้า MasterToSlaveDelay ในตอนแรกถือว่าเหมือนกันสำหรับ consecutive Sync messages, the algorithm ที่อธิบายข้างล่างนี้ต้องถูกใช้. หลังจาก a few Sync cycles, frequency lock เกิดขึ้น. The slave clock สามารถจะกำหนด a precise MasterToSlaveDelay value และ resynchronize กับ the master โดยใช้ the new value.

The algorithm เป็นดังต่อไปนี้:
•    ในเวลา MasterSyncTime (n) the master ส่ง the slave clock ด้วย a Sync message. The slave รับ message นี้เมื่อ
      local clock ของมันคือ SlaveClockTime (n) และคำนวณ MasterClockTime (n) เป็น:
      MasterClockTime (n) = MasterSyncTime (n) + MasterToSlaveDelay (n)
•    The master clock นับสำหรับ current Sync cycle, MasterClockCount (n) ถูกให้โดย:
      MasterClockCount (n) = MasterClockTime (n) – MasterClockTime (n – 1) (ทึกทักเอาว่า MasterToSlaveDelay
      เป็นเหมือนกันสำหรับ Sync cycles n และ n – 1)
•    The slave clock นับสำหรับ current Sync cycle, SlaveClockCount (n) ถูกให้โดย:
      SlaveClockCount (n) = SlaveClockTime (n) – SlaveClockTime (n – 1)
•    ความแตกต่างระหว่าง master และ slave clock counts สำหรับ current Sync cycle, ClockDiffCount (n) ถูกให้โดย:
      ClockDiffCount (n) = MasterClockCount (n) – SlaveClockCount (n)
•    The frequency-scaling factor สำหรับ slave clock, FreqScaleFactor (n) ถูกให้โดย:
      FreqScaleFactor (n) = (MasterClockCount (n) + ClockDiffCount (n)) / SlaveClockCount (n)
•    The frequency compensation value สำหรับ Addend register, FreqCompensationValue (n) ถูกให้โดย:
      FreqCompensationValue (n) = FreqScaleFactor (n) x FreqCompensationValue (n – 1)

ตามทฤษฎีแล้ว, algorithm สำเร็จการล็อคในหนึ่ง Sync cycle; อย่างไรก็ตาม, มันอาจใช้เวลาหลาย cycles, เนื่องจากการเปลี่ยน network propagation delays และ operating conditions.

algorithm นี้เป็น self-correcting: ถ้าสำหรับเหตุผลใดๆ the slave clock เริ่มต้นถูกเซ็ตเป็นค่าหนึ่งจาก the master ที่ไม่ถูกต้อง, the algorithm แก้ไขมันโดยการเสีย Sync cycles ที่มากขึ้น.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 05, 2021, 09:13:31 AM
Programming steps for system time generation initialization

The time stamping feature สามารถถูกเปิดการใช้งานโดยการเซ็ต bit 0 ใน the Time stamp control register (ETH__PTPTSCR). อย่างไรก็ตาม, มันจำเป็นอย่างยิ่งที่จะต้องเริ่มต้น the time stamp counter หลังจากบิตนี้ถูกเซ็ตเพื่อสตาร์ท time stamp operation. ลำดับที่เหมาะสมมีดังต่อไปนี้:
1.    บัง the Time stamp trigger interrupt โดยการเซ็ต bit 9 ใน the MACIMR register.
2.    โปรแกรม Time stamp register bit 0 เพื่อเปิดการใช้งาน time stamping.
3.    โปรแกรม the Subsecond increment register ขึ้นอยู่กับ the PTP clock frequency.
4.    ถ้าคุณใช้ the Fine correction method, โปรแกรม the Time stamp addend register และเซ็ต Time stamp control
       register bit 5 (addend register update).
5.    วนตรวจสอบ the Time stamp control register จนกระทั่ง bit 5 ถูกเคลียร์.
6.    เพื่อเลือก the Fine correction method (ถ้าต้องการ), โปรแกรม Time stamp control register bit 1.
7.    โปรแกรม the Time stamp high update และ Time stamp low update registers ด้วย the appropriate time value.
8.    เซ็ต Time stamp control register bit 2 (Time stamp init).
9.    The Time stamp counter สตาร์ทการทำงานทันทีที่มันถูกเริ่มต้นด้วยค่าที่ถูกเขียนใน the Time stamp update register.
10.   เปิดการใช้งาน the MAC receiver และ transmitter สำหรับ time stamping ที่เหมาะสม.

Note: ถ้า time stamp operation ถูกปิดการใช้งานโดยการเคลียร์ bit 0 ใน the ETH_PTPTSCR register, ขั้นตอนข้างบนต้องถูก
        ทำซ้ำเพื่อรีสตาร์ท the time stamp operation.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 06, 2021, 07:40:10 AM
Programming steps for system time update in the Coarse correction method

เพื่อซิงโครไนส์หรืออัปเดต the system time ใน one process (coarse correction method), ดำเนินการตามขั้นตอนต่อไปนี้:
1.    เขียน the offset (positive หรือ negative) ใน the Time stamp update high และ low registers.
2.    เซ็ต bit 3 (TSSTU) ใน the Time stamp control register.
3.    ค่าใน the Time stamp update registers ถูกเพิ่มไปยังหรือลบออกจาก the system time เมื่อ the TSSTU bit ถูกเคลียร์.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 06, 2021, 09:13:47 AM
Programming steps for system time update in the Fine correction method

เพื่อซิงโครไนส์หรืออัปเดต the system time เพื่อลด system-time jitter (fine correction method), ดำเนินการตามขั้นตอนต่อไปนี้:
1.    ด้วยความช่วยเหลือของ the algorithm ที่อธิบายใน System Time correction methods, คำนวณอัตตราส่วนที่คุณต้องการเพื่อเพิ่ม
       ความเร็วหรือทำให้ช้าลง the system time increments.
2.    อัปเดต the time stamp.
3.    รอเวลาที่คุณต้องการให้ค่าใหม่ของ the Addend register ทำงาน. คุณสามารถทำได้โดยการเปิดใช้งาน the Time stamp trigger
       interrupt หลังจาก the system time ถึงค่าเป้าหมาย.
4.    โปรแกรม the required target time ใน the Target time high and low registers. ไม่บัง the Time stamp interrupt
       โดยการเคลียร์ bit 9 ใน the ETH_MACIMR register.
5.    เซ็ต Time stamp control register bit 4 (TSARU).
6.    เมื่อ trigger นี้เป็นเหตุให้เกิด an interrupt, อ่าน the ETH_MACSR register.
7.    โปรแกรมใหม่ the Time stamp addend register ด้วยค่าเก่าและเซ็ต ETH_TPTSCR bit 5 อีกครั้ง.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 07, 2021, 06:57:33 AM
PTP trigger internal connection with TIM2

The MAC จัดให้มี a trigger interrupt เมื่อ the system time มาเป็นมากกว่า the target time. การใช้ an interrupt จะแนะนำเวลาแฝงที่รู้บวกความไม่แน่นอนใน the command execution time.

เพื่อหลีกเลี่ยงความไม่แน่นอนนี้, a PTP trigger output signal ถูกเซ็ต high เมื่อ the system time มากกว่า the target time. มันถูกเชื่อมต่อภายในไปยัง the TIM2 input trigger. ด้วยสัญญาณนี้, the input capture feature, the output compare feature และ the waveforms of the timer สามารถถูกใช้, ที่ถูกทริกโดย the synchronized PTP system time. ไม่มีความไม่แน่นอนถูกแนะนำเมื่อ the clock of the timer (PCLK1: TIM2 APB1 clock) and PTP reference clock (HCLK) ถูกซิงโครไนส์.

PTP trigger signal นี้ถูกเชื่อมต่อไปยัง the TIM2 ITR1 input เลือกได้โดย software. The connection ถูกเปิดการใช้งานผ่านทาง bit 29 ใน the AFIO_MAPR register. Figure 351 แสดง the connection.

(https://i.imgur.com/qP5MWCI.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on March 07, 2021, 07:01:55 AM
PTP pulse-per-second output signal

PTP pulse output นี้ถูกใช้เพื่อเช็ค the synchronization ระหว่างทุก nodes ใน the network. เพื่อให้สามารถทดสอบความแตกต่างระหว่าง the local slave clock และ the master reference clock, ทั้งสอง clocks ถูกให้ด้วย a pulse-per-second (PPS) output signal ที่อาจถูกต่อถึง an oscilloscope ถ้าจำเป็น. ความเบี่ยงเบนระหว่างสัญญาณทั้งสองสามารถดังนั้นถูกวัดได้. The pulse width of the PPS output คือ 125 ms.

The PPS output ถูกเปิดการใช้งานผ่านทาง bit 30 ใน the AFIO_MAPR register

(https://i.imgur.com/mIdtrL9.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on March 08, 2021, 07:05:41 AM
29.6 Ethernet functional description: DMA controller operation

The DMA มี independent transmit และ receive engines, และ a CSR space. The transmit engine ส่งถ่าย data จาก system memory ลงใน the Tx FIFO ในขณะที่ the receive engine ส่งถ่าย data จาก the Rx FIFO ลงใน system memory. The controller ใช้ให้เป็นประโยชน์ descriptors เพื่อย้าย data อย่างมีประสิทธิภาพจากต้นทางไปยังปลายทางด้วย minimum CPU intervention. The DMA ถูกออกแบบสำหรับ packet-oriented(มุ่งไปยัง) data transfers อย่างเช่น frames ใน Ethernet. The controller สามารถถูกโปรแกรมเพื่ออินเตอร์รัพท์ the CPU ในกรณีอย่างเช่น frame transmit and receive transfer completion, และ other normal/error conditions. The DMA และ the STM32F107xx สื่อสารผ่านทาง two data structures:

• Control and status registers (CSR)
• Descriptor lists and data buffers.

Control and status registers ถูกอธิบายในรายละเอียดใน Section 29.8. Descriptors ถูกอธิบายในรายละเอียดใน Tx DMA descriptors.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 08, 2021, 08:55:51 AM
The DMA ส่งถ่าย the received data frames ไปยัง the receive buffer ใน the STM32F107xxmemory, และส่ง data frames จาก the transmit buffer ใน the STM32F107xx memory. Descriptors ที่อาศัยอยู่ใน the STM32F107xx memory ทำหน้าที่เป็น pointers ไปยัง buffers เหล่านี้. มี two descriptor lists: หนึ่งสำหรับ reception, และหนึ่งสำหรับ transmission. The base address ของแต่ละรายการถูกเขียนลงใน DMA Registers 3 and 4, ตามลำดับ. A descriptor list มีการเชื่อมโยงไปข้างหน้า (อย่างใดอย่างหนึ่งโดยนัยหรืออย่างชัดเจน). The last descriptor อาจชี้กลับไปที่ the first entry เพื่อสร้าง a ring structure. การเชื่อมโยงอย่างชัดเจนของ descriptors ถูกทำให้สำเร็จลงโดยการกำหนดค่า the second address ที่เชื่อมโยงในทั้ง the receive และ transmit descriptors (RDES1[14] and TDES0[20]). The descriptor lists อาศัยอยู่ใน the Host's physical memory space. แต่ละ descriptor สามารถชี้ไปยังจุดสูงสุดของสอง buffers. นี้เปิดการใช้งานการใช้ของ two physically addressed buffers, แทนที่จะเป็นสอง buffers ที่อยู่ติดกันใน memory. A data buffer ที่อาศัยอยู่ใน the Host's physical memory space, และประกอบด้วยเฟรมทั้งหมดหรือบางส่วนของเฟรม, แต่ไม่สามารถเกิน a single frame. Buffers บรรจุเฉพาะ data. The buffer status ถูกเก็บรักษาใน the descriptor. Data chaining อ้างอิงถึง frames ที่ทอดข้ามหลาย data buffers. อย่างไรก็ตาม, a single descriptor ไม่สามารถทอดข้ามหลาย frames. The DMA ข้ามไปยัง the next frame buffer เมื่อ the end of frame ถูกตรวจพบ. Data chaining สามารถถูก enabled หรือ disabled. The descriptor ring และ chain structure ถูกแสดงใน Figure 353.

(https://i.imgur.com/9XCUSaT.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on March 09, 2021, 07:17:26 AM
29.6.1 Initialization of a transfer using DMA

การเริ่มต้นสำหรับ the MAC เป็นดังต่อไปนี้:
1.    เขียนไปยัง ETH_DMABMR เพื่อเซ็ต STM32F107xx bus access parameters.
2.    เขียนไปยัง the ETH_DMAIER register เพื่อบัง interrupt causes ที่ไม่จำเป็น.
3.    The software driver สร้าง the transmit and receive descriptor lists. จากนั้นมันเขียนไปยังทั้ง the ETH_DMARDLAR
       และ ETH_DMATDLAR registers, จัดให้ the DMA ด้วย the start address ของแต่ละรายการ.
4.    เขียนไปยัง MAC Registers 1, 2, and 3 เพื่อเลือก the desired filtering options
5.    เขียนไปยัง the MAC ETH_MACCR register เพื่อกำหนดค่าและเปิดการใช้งาน the transmit and receive operating modes.
       The PS and DM bits ถูกเซ็ตขึ้นอยู่กับ the auto-negotiation result (ที่อ่านจาก the PHY).
6.    เขียนไปยัง the ETH_DMAOMR register เพื่อเซ็ต bits 13 and 1 และสตาร์ท transmission and reception.
7.    The transmit and receive engines เข้าสู่ the running state และพยายามให้ได้มาซึ่ง descriptors จาก the respective
       descriptor lists. The receive and transmit engines จากนั้นเริ่มการประมวลผล receive and transmit operations. The
       transmit and receive processes เป็นอิสระซึ่งกันและกันและสามารถสตาร์ทหรือหยุดแยกกัน.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 09, 2021, 09:00:14 AM
29.6.2 Host bus burst access

The DMA พยายามปฏิบัติ fixed-length burst transfers บน the AHB master interface ถ้าถูกกำหนดค่าเพื่อให้ทำ (FB bit ใน ETH_DMABMR). The maximum burst length ถูกแสดงให้เห็นและจำกัดโดย the PBL field (ETH_DMABMR [13:8]). The receive and transmit descriptors ถูกเข้าถึงเสมอใน the maximum possible burst size (จำกัดโดย PBL) สำหรับ the 16 bytes ที่จะถูกอ่าน.

The Transmit DMA เริ่มต้น a data transfer เฉพาะเมื่อมีพื้นที่ว่างเพียงพอใน the Transmit FIFO เพื่อรองรับ the configured burst หรือ the number of bytes จนกระทั่ง the end of frame (เมื่อมันน้อยกว่า the configured burst length). The DMA แสดงให้เห็น the start address และ the number of transfers ที่ต้องการไปยัง the AHB Master Interface. เมื่อ the AHB Interface ถูกกำหนดค่าสำหรับ fixed-length burst, จากนั้นมันส่งถ่าย data โดยใช้ the best combination of INCR4, INCR8, INCR16 and SINGLE transactions. มิฉะนั้น (no fixed-length burst), มันส่งถ่าย data โดยใช้ INCR (ไม่กำหนดความยาว) and SINGLE transactions.

The Receive DMA เริ่มต้น a data transfer เฉพาะเมื่อมี data เพียงพอสำหรับ the configured burst มีให้ใช้ใน Receive FIFO หรือเมื่อ the end of frame (เมื่อมันน้อยกว่า the configured burst length) ถูกตรวจพบใน the Receive FIFO. The DMA แสดงให้เห็น the start address และ the number of transfers ที่ต้องการไปยัง the AHB master interface. เมื่อ the AHB interface ถูกกำหนดค่าสำหรับ fixed-length burst, จากนั้นมันส่งถ่าย data โดยใช้ the best combination of INCR4, INCR8, INCR16 and SINGLE transactions. ถ้า the end of frame ถูกถึงก่อน the fixed-burst สิ้นสุดบน the AHB interface, จากนั้น dummy transfers ถูกดำเนินการเพื่อเสร็จสมบูรณ์ the fixed-length burst. มิฉะนั้น (FB bit ใน ETH_DMABMR ถูก reset),  มันส่งถ่าย data โดยใช้ INCR (ไม่กำหนดความยาว) and SINGLE transactions.

เมื่อ the AHB interface ถูกกำหนดค่าสำหรับ address-aligned beats, ทั้งสอง DMA engines ทำให้แน่ใจว่า the first burst transfer the AHB initiates น้อยกว่าหรือเท่ากับขนาดของ the configured PBL. ดังนั้น, beats ที่ตามมาทั้งหมดจะสตาร์ทที่ an address ที่ถูกจัดแนวตาม the configured PBL. The DMA สามารถจัดแนวเฉพาะ the address สำหรับ beats สูงถึงขนาด 16 (สำหรับ PBL > 16), เพราะ the AHB interface ไม่รองรับมากกว่า INCR16.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 10, 2021, 07:03:51 AM
29.6.3 Host data buffer alignment

The transmit and receive data buffers ไม่มีข้อจำกัดใดๆบน start address alignment. ในระบบของเราที่มี 32-bit memory, the start address สำหรับ the buffers สามารถถูกจัดแนวให้ตรง the four bytes ใดก็ได้. อย่างไรก็ตาม, the DMA เริ่มต้น transfers ด้วย address ที่จัดแนวให้ตรง the bus width เสมอด้วย dummy data สำหรับ the byte lanes ที่ไม่ต้องการ.  โดยทั่วไปจะเกิดขึ้นในช่วง the transfer ของ the beginning หรือ end of an Ethernet frame.

•    ตัวอย่างของ buffer read:
      ถ้า the Transmit buffer address คือ 0x0000 0FF2, และ 15 bytes ต้องการที่จะถูกส่งถ่าย, จากนั้น the DMA จะอ่าน 5 
      words เติมจาก address 0x0000 0FF0, แต่เมื่อการส่งถ่าย data ไปยัง the Transmit FIFO, the extra bytes ( 2 bytes
      แรก) จะถูกดร็อปหรือละเว้น. ในทำนองเดียวกัน, the last 3 bytes ของ the last transfer ก็จะถูกละเว้นด้วยเหมือนกัน. The DMA
      ทำให้แน่ใจเสมอว่ามันส่งถ่าย a full 32-bit data items ไปยัง the Transmit FIFO, เว้นแต่มันเป็น the end of frame.

•    ตัวอย่างของ buffer write:
      ถ้า the Receive buffer address คือ 0x0000 0FF2, และ 16 bytes ของ a received frame ต้องการที่จะถูกส่งถ่าย, จากนั้น
      the DMA จะเขียน five full 32-bit data items จาก address 0x0000 0FF0. แต่ the first 2 bytes of the first transfer
      และ the last 2 bytes of the third transfer จะมี dummy data.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 10, 2021, 09:17:18 AM
29.6.4 Buffer size calculations

The DMA จะไม่อัปเดต the size fields ใน the transmit and receive descriptors. The DMA อัปเดตเฉพาะ the status fields (xDES0) ของ the descriptors. The driver ต้องคำนวณ the sizes. The transmit DMA ส่งถ่าย the exact number of bytes (ที่แสดงให้เห็นโดย buffer size field ใน TDES1) ไปยัง the MAC core. ถ้า a descriptor ถูกทำเครื่องหมายเป็นตัวแรก (FS bit ใน TDES0 ถูก set), จากนั้น the DMA ทำเครื่องหมาย the first transfer จาก the buffer เป็น the start of frame. ถ้า a descriptor ถูกทำเครื่องหมายเป็นตัวสุดท้าย (LS bit in TDES0), จากนั้น the DMA ทำเครื่องหมาย the last transfer จาก data buffer นั้นเป็น the end of frame. The receive DMA ส่งถ่าย data ไปยัง a buffer จนกระทั่ง the buffer นั้นเต็มหรือ the end of frame ถูกรับ. ถ้า a descriptor ไม่ถูกทำเครื่องหมายเป็นตัวสุดท้าย (LS bit in RDES0), จากนั้น the buffer(s) ที่ตรงกันกับ the descriptor จะเต็มและจำนวนของ valid data ใน a buffer ถูกแสดงให้เห็นอย่างถูกต้องโดย the buffer size field ลบ the data buffer pointer offset เมื่อ the descriptor's FS bit ถูก set. The offset เป็นศูนย์เมื่อ the data buffer pointer ถูกจัดแนวให้ตรง the databus width.  ถ้า a descriptor ถูกทำเครื่องหมายเป็นตัวสุดท้าย, จากนั้น the buffer อาจจะไม่เต็ม (ดังแสดงให้เห็นโดย the buffer size ใน RDES1). เพื่อคำนวณจำนวนของ valid data ใน final buffer นี้, the driver ต้องอ่าน the frame length (FL bits ใน RDES0[29:16]) และลบผลรวมของ the buffer sizes ของ buffers ก่อนหน้านี้ใน frame นี้. The receive DMA ส่งถ่าย the start of next frame ด้วย a new descriptor เสมอ.

Note : แม้ว่าเมื่อ the start address of a receive buffer ไม่ถูกจัดแนวให้ตรง the system databus width the system ควรจัดสรร a receive buffer of a size ถูกจัดแนวให้ตรง the system bus width. ตัวอย่างเช่น, ถ้า the system จัดสรร a 1024 byte (1 KB) receive buffer โดยเริ่มจาก address 0x1000, the software สามารถโปรแกรม the buffer start address ใน the receive descriptor ให้มี a 0x1002 offset. The receive DMA เขียน the frame ไปยัง buffer นี้ด้วย dummy data ใน the first two locations (0x1000 and 0x1001). The actual frame ถูกเขียนจาก location 0x1002. ดังนั้น, the actual useful space ใน buffer นี้คือ 1022 bytes, แม้ว่า the buffer size ถูกโปรแกรมเป็น 1024 bytes, เนื่องจาก the start address offset
Title: Re: STM32F1 ETHERNET
Post by: tha on March 11, 2021, 07:16:16 AM
29.6.5 DMA arbiter

ตัวตัดสินภายใน the DMA จะดูแลการตัดสินระหว่าง transmit and receive channel เข้าถึงไปยัง the AHB master interface. สองประเภทของ arbitrations ที่เป็นไปได้: round-robin, และ fixed-priority. เมื่อ round-robin arbitration ถูกเลือก (DA bit ใน ETH_DMABMR ถูก reset), the arbiter จัดสรร the databus ในอัตราส่วนที่เซ็ตโดย the PM bits ใน ETH_DMABMR, เมื่อทั้ง transmit and receive DMAs request access เกิดขึ้นพร้อมกัน. เมื่อ the DA bit ถูก set, the receive DMA จะได้รับ priority เหนือกว่า the transmit DMA เสมอสำหรับ data access.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 11, 2021, 08:38:22 AM
29.6.6 Error response to DMA

สำหรับ data transfer ใดๆที่เริ่มต้นโดย a DMA channel, ถ้า the slave ตอบกลับด้วย an error response, DMA นั้นจะหยุดการทำงานทั้งหมดและอัปเดต the error bits และ the fatal bus error bit ใน the Status register (ETH_DMASR register). DMA controller นั้นสามารถกลับคืนการทำงานเฉพาะหลังจากr soft- or hard-resetting the peripheral และการเริ่มต้นใหม่ the DMA.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 12, 2021, 07:12:49 AM
29.6.7 Tx DMA configuration

TxDMA operation: default (non-OSF) mode

The transmit DMA engine ใน default mode จะดำเนินการดังต่อไปนี้ :
1.    ผู้ใช้ตั้งค่า the transmit descriptor (TDES0-TDES3) และเซ็ต the OWN bit (TDES0[31]) หลังจากการตั้งค่า the
       corresponding data buffer(s) ด้วย Ethernet frame data.
2.    เมื่อ the ST bit (ETH_DMAOMR register[13]) ถูก set, the DMA จะเข้าสู่ the Run state.
3.    ในขณะที่อยู่ใน the Run state, the DMA วนตรวจ the transmit descriptor list เพื่อ frames ที่ต้องการ transmission. หลัง
       จากการวนตรวจสตาร์ท, มันดำเนินการต่อในอย่างใดอย่างหนึ่ง sequential descriptor ring order หรือ chained order. ถ้า the
       DMA ตรวจพบ a descriptor ที่ป้ายชื่อว่าเป็นเจ้าของโดย the CPU, หรือถ้า an error condition เกิดขึ้น, transmission จะถูก
       ระงับและทั้ง the Transmit Buffer Unavailable (ETH_DMASR register[2]) and Normal Interrupt Summary
       (ETH_DMASR register[16]) bits ถูก set. The transmit engine ดำเนินไปยัง Step 9.
4.    ถ้า the acquired descriptor ถูกป้ายชื่อว่าเป็นเจ้าของโดย DMA (TDES0[31] ถูก set), the DMA ถอดรหัส the transmit
       data buffer address จาก the acquired descriptor.
5.    The DMA ดึง the transmit data จาก the STM32F107xx memory และส่งถ่าย the data.
6.    ถ้า an Ethernet frame ถูกเก็บเหนือ data buffers ใน multiple descriptors, the DMA ปิด the intermediate descriptor
       และดึง the next descriptor. Steps 3, 4, and 5 ถูกทำซ้ำจนกระทั่ง the end of Ethernet frame data ถูกส่งถ่าย.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 12, 2021, 07:33:14 AM
7.    เมื่อ frame transmission เสร็จสมบูรณ์, if IEEE 1588 time stamping ถูกเปิดการใช้งานแล้วสำหรับ the frame (ดังแสดงให้
       เห็นใน the transmit status) the time stamp value ถูกเขียนไปยัง the transmit descriptor (TDES2 and TDES3) ที่
       บรรจุ the end-of-frame buffer. The status information จากนั้นถูกเขียนไปยัง transmit descriptor (TDES0) นี้. เพราะ
       the OWN bit ถูกเคลียร์ในระหว่างขั้นตอนนี้, the CPU ตอนนี้เป็นเจ้าของ descriptor นี้. ถ้า time stamping ไม่ได้ถูกเปิดการใช้
       งานสำหรับ frame นี้, the DMA จะไม่เปลี่ยนแปลง the contents of TDES2 and TDES3
8.    Transmit Interrupt (ETH_DMASR register[0]) ถูกเซ็ตหลังจากการเสร็จสมบูรณ์ the transmission of a frame ที่มี
       Interrupt บน Completion (TDES1[31]) เซ็ตใน last descriptor ของมัน. The DMA engine จากนั้นกลับคืนไปยัง Step 3.
9.    ใน the Suspend state, the DMA พยายามให้ได้มาใหม่ the descriptor (และด้วยเหตุนี้กลับไปยัง Step 3) เมื่อมันรับ a
       transmit poll demand, และ the Underflow Interrupt Status bit ถูกเคลียร์.

Figure 354 แสดง the TxDMA transmission flow ใน default mode.

(https://i.imgur.com/Y2po9Yc.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on March 12, 2021, 11:16:46 AM
TxDMA operation: OSF mode

ในขณะที่อยู่ the Run state, the transmit process สามารถได้รับสอง frames พร้อมกันโดยไม่ต้องปิด the Status descriptor ของตัวแรก (if the OSF bit ถูกเซ็ตใน ETH_DMAOMR register[2]). เมื่อ the transmit process สำเร็จการส่งถ่าย the first frame, มันจะวนตรวจ the transmit descriptor list สำหรับ the second frame ทันที. ถ้า the second frame ใช้ได้, the transmit process ส่งถ่าย frame นี้ก่อนการเขียน the first frame's status information. ใน OSF mode, the Run-state transmit DMA ทำงานสอดคล้องกับลำดับต่อไปนี้ :
1.    The DMA ทำงานตามที่อธิบายใน steps 1–6 ของ the TxDMA (default mode).
2.    โดยไม่ต้องปิด the previous frame's last descriptor, the DMA ดึง the next descriptor.
3.    ถ้า the DMA เป็นเจ้าของ the acquired descriptor, the DMA จะถอดระหัส the transmit buffer address ใน descriptor
       นี้. ถ้า the DMA ไม่ได้เป็นเจ้าของ the descriptor, the DMA ไปลงใน Suspend mode และข้ามไปยัง Step 7.
4.    The DMA ดึง the Transmit frame จาก the STM32F107xx memory และส่งถ่าย the frame จนกระทั่ง the end of frame
       data ถูกส่งถ่าย, ปิด the intermediate descriptors ถ้า frame นี้ถูกแยกออกข้ามไปหลาย descriptors.
5.    The DMA คอยสำหรับ the transmission status และ time stamp ของ the previous frame. เมื่อ the status มีให้ใช้งาน,
       the DMA เขียน the time stamp ไปยัง TDES2 and TDES3, ถ้า time stamp ดังกล่าวถูกจับแล้ว (ดังแสดงให้เห็นโดย a
       status bit). The DMA จากนั้นเขียน the status, พร้อมกับการเคลียร์ OWN bit, ไปยัง the corresponding TDES0, ดังนั้นปิด
       the descriptor. ถ้า time stamping ไม่ถูกเปิดการใช้งานสำหรับ the previous frame, the DMA จะไม่เปลี่ยนแปลง the
       contents of TDES2 and TDES3.
6.    ถ้าถูกเปิดการใช้งาน, the Transmit interrupt ถูกเซ็ต, the DMA ดึง the next descriptor, จากนั้นดำเนินไปยัง Step 3 (เมื่อ
       Status เป็นปกติ). ถ้า the previous transmission status แสดง an underflow error, the DMA ไปลงใน Suspend mode
       (Step 7).
7.    ใน Suspend mode, ถ้า a pending status และ time stamp ถูกรับโดย the DMA, มันจะเขียน the time stamp (ถ้าถูกเปิด
       การใช้งานสำหรับ the current frame) ไปยัง TDES2 and TDES3, จากนั้นเขียน the status ไปยัง the corresponding
       TDES0. จากนั้นเซ็ต interrupts ที่เกี่ยวข้องและกลับคืนไปยัง Suspend mode.
8.    The DMA สามารถออกจาก Suspend mode และเข้าสู่ the Run state (ไปยัง Step 1 หรือ Step 2 ขึ้นอยู่กับ pending status)
       เฉพาะหลังจากการรับ a Transmit Poll demand (ETH_DMATPDR register).

Figure 355 แสดง the basic flowchart ใน OSF mode

(https://i.imgur.com/m17z2gZ.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on March 13, 2021, 07:15:18 AM
Transmit frame processing

The transmit DMA คาดว่า the data buffers บรรจุ complete Ethernet frames, ไม่รวม preamble, pad bytes, และ FCS fields. The DA, SA, and Type/Len fields บรรจุ valid data. ถ้า the transmit descriptor แสดงให้เห็นว่า the MAC core ต้องปิดการใช้งาน CRC หรือ pad insertion, the buffer ต้องมี complete Ethernet frames (ไม่รวม preamble), รวมทั้ง the CRC bytes. Frames สามารถเป็น data-chained และขยายผ่านหลายๆ buffers. Frames ต้องถูกคั่นด้วย the first descriptor (TDES0[28]) และ the last descriptor (TDES0[29]). ตอนที่ the transmission สตาร์ท, TDES0[28] ต้องถูกเซ็ตใน the first descriptor. เมื่อสิ่งนี้เกิดขึ้น, the frame data ถูกส่งถ่ายจาก the memory buffer ไปยัง the Transmit FIFO. ในขณะเดียวกัน, ถ้า the last descriptor (TDES0[29]) ของ the current frame ถูกเคลียร์, the transmit process พยายามให้ได้รับ the next descriptor. The transmit process คาดว่า TDES0[28] จะถูกเคลียร์ใน descriptor นี้. ถ้า TDES0[29] ถูกเคลียร์, มันแสดงให้เห็น an intermediary buffer. ถ้า TDES0[29] ถูกเซ็ต, มันแสดงให้เห็น the last buffer of the frame. หลังจาก the last buffer of the frame ถูกส่งแล้ว, the DMA เขียน the final status information กลับไปยัง the transmit descriptor 0 (TDES0) word of the descriptor ที่มี the last segment เซ็ตใน transmit descriptor 0 (TDES0[29]). ที่เวลานี้, ถ้า Interrupt on Completion (TDES0[30]) ถูกเซ็ต, Transmit Interrupt (ใน ETH_DMASR register[0]) ถูกเซ็ต, the next descriptor ถูกดึง, และ the process ทำซ้ำ. Actual frame transmission เริ่มต้นหลังจาก the Transmit FIFO ถึงอย่างใดอย่างหนึ่ง a programmable transmit threshold (ETH_DMAOMR register[16:14]), หรือ a full frame ถูกบรรจุใน the FIFO. มีทางเลือกสำหรับ the Store และ forward mode (ETH_DMAOMR register[21]) อีกด้วย. Descriptors ถูกปลดปล่อย (OWN bit TDES0[31] ถูกเคลียร์) เมื่อ the DMA เสร็จการส่งถ่าย the frame.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 13, 2021, 09:43:32 AM
Transmit polling suspended

Transmit polling สามารถถูกระงับ(แขวน)ไว้โดยอย่างใดอย่างหนึ่งของเงื่อนไขต่อไปนี้:
•    The DMA ตรวจพบ a descriptor เป็นเจ้าของโดย the CPU (TDES0[31]=0) และ the Transmit buffer unavailable flag
      ถูกเซ็ต (ETH_DMASR register[2]). เพื่อดำเนินการต่อ, the driver ต้องให้ descriptor ownership แก่ the DMA และจากนั้น
      ปล่อยออก a Poll Demand command.
•    A frame transmission ถูกยกเลิกเมื่อ a transmit error เนื่องจาก underflow ถูกตรวจพบ. The appropriate Transmit
      Descriptor 0 (TDES0) bit ถูกเซ็ต. ถ้า the second condition เกิดขึ้น, ทั้ง the Abnormal Interrupt Summary (ใน
      ETH_DMASR register [15]) และ Transmit Underflow bits (ใน ETH_DMASR register[5]) ถูกเซ็ต, และ the
      information ถูกเขียนไปยัง Transmit Descriptor 0, สาเหตุของ the suspension. ถ้า the DMA ไปลงใน Suspend state
      เนื่องจาก the first condition, จากนั้นทั้ง the Normal Interrupt Summary (ETH_DMASR register [16]) และ Transmit
      Buffer Unavailable (ETH_DMASR register[2]) bits ถูกเซ็ต. ในทั้งสองกรณี, ตำแหน่งใน the transmit list ถูกเก็บไว้. The
      retained position นั้นคือ the descriptor ที่ตาม the last descriptor ที่ปิดโดย the DMA. The driver ต้องปล่อยออกอย่าง
      แน่ชัด a Transmit Poll Demand command หลังจากการแก้ไข the suspension cause.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 14, 2021, 07:21:46 AM
Tx DMA descriptors

The descriptor structure ประกอบด้วย four 32-bit words ดังแสดงใน Figure 356. The bit descriptions ของ TDES0, TDES1, TDES2 and TDES3 ถูกให้ข้างล่างนี้.

(https://i.imgur.com/GeMU65H.png)

•    TDES0: Transmit descriptor Word0

The application software ต้องโปรแกรม the control bits [30:26]+[23:20] บวกกับ the OWN bit [31] ในระหว่าง descriptor initialization. เมื่อ the DMA อัปเดต the descriptor (หรือเขียนมันกลับ), มันจะรีเซ็ตทุก the control bits บวกกับ the OWN bit, และรายงานเฉพาะ the status bits.

(https://i.imgur.com/YLrhwlI.png)

Bit 31 OWN: Own bit
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the descriptor ถูกเป็นเจ้าของโดย the DMA. เมื่อบิตนี้ถูกรีเซ็ต, มันแสดงให้เห็นว่า the descriptor ถูกเป็นเจ้าของโดย the CPU. The DMA เคลียร์บิตนี้อย่างใดอย่างหนึ่งเมื่อมันเสร็จสมบูรณ์ the frame transmission หรือเมื่อ the buffers ที่จัดสรรใน the descriptor ถูกอ่านเสร็จสมบูรณ์. The ownership bit of the frame's first descriptor ต้องถูกเซ็ตหลังจาก descriptors ที่ตามมาทั้งหมดที่เป็นของ the same frame ถูกเซ็ตแล้ว.

Bit 30 IC: Interrupt on completion
เมื่อเซ็ต, บิตนี้เซ็ต the Transmit Interrupt (Register 5[0]) หลังจาก the present frame ถูกส่งแล้ว.

Bit 29 LS: Last segment
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the buffer บรรจุ the last segment of the frame.

Bit 28 FS: First segment
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the buffer บรรจุ the first segment of a frame.

Bit 27 DC: Disable CRC
เมื่อบิตนี้ถูกเซ็ต, the MAC ไม่ได้ต่อท้าย a cyclic redundancy check (CRC) ไปยัง the end of the transmitted frame. นี้ใช้ได้เฉพาะเมื่อ the first segment (TDES0[28]) ถูกเซ็ต.

Bit 26 DP: Disable pad
เมื่อเซ็ต, the MAC จะไม่เพิ่ม padding โดยอัตโนมัติไปยัง a frame ที่สั้นกว่า 64 bytes. เมื่อบิตนี้ถูกรีเซ็ต, the DMA จะเพิ่ม padding โดยอัตโนมัติและ CRC ไปยัง a frame ที่สั้นกว่า 64 bytes, และ the CRC field ถูกเพิ่มแม้จะมี the state of the DC (TDES0[27]) bit. นี้ใช้ได้เฉพาะเมื่อ the first segment (TDES0[28]) ถูกเซ็ต.

Bit 25 TTSE: Transmit time stamp enable
เมื่อ TTSE ถูกเซ็ตและเมื่อ TSE ถูกเซ็ต (ETH_PTPTSCR bit 0), IEEE1588 hardware time stamping ถูกทำให้ทำงานสำหรับ the transmit frame ที่อธิบายโดย the descriptor. field นี้ใช้ได้เฉพาะเมื่อ the First segment control bit (TDES0[28]) ถูกเซ็ต.

Bit 24 สงวนไว้, ต้องถูกเก็บไว้ที่ค่ารีเซ็ต.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 14, 2021, 09:24:07 AM
Bits 23:22 CIC: Checksum insertion control
บิตเหล่านี้ควบคุม the checksum calculation และ insertion. Bit encoding เป็นดังแสดงข้างล่าง:
     00: Checksum Insertion ถูกปิดการใช้งาน
     01: เฉพาะ IP header checksum calculation และ insertion ถูกเปิดการใช้งาน
     10: IP header checksum และ payload checksum calculation และ insertion ถูกเปิดการใช้งาน, แต่ pseudo-header
           checksum ไม่ถูกคำนวณใน hardware
     11: IP Header checksum and payload checksum calculation and insertion ถูกเปิดการใช้งาน, and pseudo-header
           checksum ถูกคำนวณใน hardware.

Bit 21 TER: Transmit end of ring
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the descriptor list ถึง final descriptor ของมัน. The DMA กลับคืนไปยัง the base address of the list, สร้าง a descriptor ring.

Bit 20 TCH: Second address chained
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the second address ใน the descriptor เป็น the next descriptor address แทนที่จะเป็น the second buffer address. เมื่อ TDES0[20] ถูกเซ็ต, TBS2 (TDES1[28:16]) เป็นค่า "ที่ไม่ต้องสนใจ" . TDES0[21]  มีลำดับความสำคัญเหนือกว่า TDES0[20].

Bits 19:18 สงวนไว้, ต้องถูกเก็บไว้ที่ค่ารีเซ็ต.

Bit 17 TTSS: Transmit time stamp status
ฟิลด์นี้ถูกใช้เป็น a status bit เพื่อแสดงให้เห็นว่า a time stamp ถูกจับแล้วสำหรับ the described transmit frame. เมื่อบิตนี้ถูกเซ็ต, TDES2 and TDES3 มี a time stamp value ที่จับสำหรับ the transmit frame. ฟิลด์นี้ใช้ได้เฉพาะเมื่อ the descriptor's Last segment control bit (TDES0[29]) ถูกเซ็ต.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 14, 2021, 11:24:19 AM
Bit 16 IHE: IP header error
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the MAC transmitter ตรวจพบ an error ใน the IP datagram header. The transmitter เช็ค the header length ใน the IPv4 packet เทียบกับ the number of header bytes ที่รับมาจาก the application และแสดงให้เห็น an error status ถ้ามีการไม่ตรงกัน. สำหรับ IPv6 frames, a header error ถูกรายงานถ้า the main header length ไม่ใช่ 40 bytes. นอกจากนี้, the Ethernet length/type field value สำหรับ an IPv4 or IPv6 frame ต้องตรงกับ the IP header version ที่ได้รับพร้อมกับ the packet. สำหรับ IPv4 frames, an error status ถูกแสดงให้เห็นอีกด้วยถ้า the Header Length field มีค่าน้อยกว่า 0x5.

Bit 15 ES: Error summary
แสดงให้เห็นลอจิก OR ของบิตต่อไปนี้:
TDES0[14]: Jabber timeout
TDES0[13]: Frame flush
TDES0[11]: Loss of carrier
TDES0[10]: No carrier
TDES0[9]: Late collision
TDES0[8]: Excessive collision
TDES0[2]:Excessive deferral
TDES0[1]: Underflow error
TDES0[16]: IP header error
TDES0[12]: IP payload error

Bit 14 JT: Jabber timeout
เมื่อเซ็ต, บิตนี้แสดงให้เห็น the MAC transmitter ประสบปัญหา a jabber timeout. บิตนี้ถูกเซ็ตเฉพาะเมื่อ the MAC configuration register's JD bit ไม่ถูกเซ็ต.

Bit 13 FF: Frame flushed
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the DMA/MTL ล้าง the frame เนื่องจาก a software Flush command ที่ให้โดย the CPU.

Bit 12 IPE: IP payload error
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า MAC transmitter ตรวจพบ an error ใน the TCP, UDP, or ICMP IP datagram payload. The transmitter เช็ค the payload length ที่ได้รับใน the IPv4 or IPv6 header เทียบกับ the actual number of TCP, UDP or ICMP packet bytes ที่ได้รับจาก the application และปล่อยออก an error status ในกรณีที่ไม่ตรงกัน.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 15, 2021, 07:41:28 AM
Bit 11 LCA: Loss of carrier
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า a loss of carrier เกิดขึ้นในระหว่าง frame transmission (นั่นคือ, the MII_CRS signal อยู่เฉยเป็นเวลาหนึ่งหรือมากกว่า transmit clock periods ในระหว่าง frame transmission). นี้ใช้ได้เฉพาะสำหรับ the frames ที่ส่งโดยไม่มี collision เมื่อ the MAC ทำงานใน Half-duplex mode.

Bit 10 NC: No carrier
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the Carrier Sense signal จาก the PHY ไม่ถูกถือสิทธิ์ในระหว่าง transmission.

Bit 9 LCO: Late collision
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า frame transmission ถูกยกเลิกเนื่องจาก a collision เกิดขึ้นหลังจาก the collision window (64 byte times, รวมถึง preamble, ใน MII mode). บิตนี้ใช้ไม่ได้ถ้า the Underflow Error bit ถูกเซ็ต.

Bit 8 EC: Excessive collision
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the transmission ถูกยกเลิกหลังจาก 16 successive collisions ในขณะที่พยายามส่ง the current frame. ถ้า the RD (Disable retry) bit ใน the MAC Configuration register ถูกเซ็ต, บิตนี้จะถูกเซ็ตหลังจาก the first collision, และ the transmission of the frame ถูกยกเลิก.

Bit 7 VF: VLAN frame
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the transmitted frame เป็น a VLAN-type frame.

Bits 6:3 CC: Collision count
This 4-bit counter value แสดงให้เห็น the number of collisions เกิดขึ้นก่อน the frame ถูกส่ง. The count ใช้ไม่ได้เมื่อ the Excessive collisions bit (TDES0[8]) ถูกเซ็ต.

Bit 2 ED: Excessive deferral
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the transmission ได้สิ้นสุดลงเพราะว่า excessive deferral มากกว่า 24 288 bit ครั้งถ้า the Deferral check (DC) bit ใน the MAC Control register ถูกเซ็ตเป็น high.

Bit 1 UF: Underflow error
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the MAC ยกเลิก the frame เนื่อกจาก data มาถึงช้าจาก the RAM memory. Underflow error แสดงให้เห็นว่า the DMA ประสบ an empty transmit buffer ขณะที่ส่ง the frame. The transmission process เข้าสู่ the Suspended state และเซ็ตทั้ง Transmit underflow (Register 5[5]) และ Transmit interrupt (Register 5[0]).

Bit 0 DB: Deferred bit
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the MAC ชลอก่อน transmission เนื่องจากการปรากฎตัวของ the carrier. บิตนี้ใช้ได้เฉพาะใน Half-duplex mode.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 15, 2021, 09:03:20 AM
•    TDES1: Transmit descriptor Word1

(https://i.imgur.com/G9kk9pg.png)

31:29 Reserved, must be kept at reset value.

28:16 TBS2: Transmit buffer 2 size
บิตเหล่านี้แสดงให้เห็น the second data buffer size เป็น bytes. ฟิลด์นี้ใช้ไม่ได้ถ้า TDES0[20] ถูกเซ็ต.

15:13 Reserved, must be kept at reset value.

12:0 TBS1: Transmit buffer 1 size
บิตเหล่านี้แสดงให้เห็น the first data buffer byte size, เป็น bytes. ถ้าฟิลด์นี้เป็น 0, the DMA จะละเว้น buffer นี้และใช้ Buffer 2 หรือ the next descriptor, ขึ้นอยู่กับค่าของ TCH (TDES0[20]).
Title: Re: STM32F1 ETHERNET
Post by: tha on March 15, 2021, 10:01:08 AM
•    TDES2: Transmit descriptor Word2

TDES2 บรรจุ the address pointer ไปยัง the first buffer of the descriptor หรือมันบรรจุ time stamp data.

(https://i.imgur.com/v6eRH5m.png)

Bits 31:0 TBAP1: Transmit buffer 1 address pointer / Transmit frame time stamp low
บิตเหล่านี้มีสองหน้าที่ที่แตกต่างกัน: พวกมันแสดงให้เห็นไปยัง the DMA ถึงตำแหน่งของ data ใน memory, และหลังจาก data ทั้งหมดถูกส่งถ่ายแล้ว, the DMA สามารถจากนั้นใช้บิตเหล่านี้เพื่อส่งกลับ time stamp data.

TBAP: เมื่อ the software ทำให้ descriptor นี้พร้อมใช้งานสำหรับ the DMA (ในขณะที่ the OWN bit ถูกเซ็ตเป็น 1 ใน TDES0), บิตเหล่านี้แสดงให้เห็น the physical address of Buffer 1. ไม่มีข้อจำกัดบน the buffer address alignment. ดู Host data buffer alignment สำหรับรายละเอียดที่มากขึ้นบน buffer address alignment.

TTSL: ก่อนที่จะเคลียร์ the OWN bit ใน TDES0, the DMA อัปเดตฟิลด์นี้ด้วย the 32 least significant bits ของ the time stamp ที่จับสำหรับ the corresponding transmit frame (เขียนทับค่าสำหรับ TBAP1). ฟิลด์นี้มี the time stamp เฉพาะถ้า time stamping ถูกทำให้ทำงานสำหรับ frame นี้ (ดู TTSE, TDES0 bit 25) และถ้า the Last segment control bit (LS) ใน the descriptor ถูกเซ็ต.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 15, 2021, 10:53:32 AM
•    TDES3: Transmit descriptor Word3

TDES3 บรรจุ the address pointer อย่างใดอย่างหนึ่งไปยัง the second buffer of the descriptor หรือ the next descriptor, หรือมันบรรจุ time stamp data.

(https://i.imgur.com/cAQa8LJ.png)

Bits 31:0 TBAP2: Transmit buffer 2 address pointer (Next descriptor address) / Transmit frame time stamp high
บิตเหล่านี้มีสองหน้าที่ที่แตกต่างกัน: พวกมันแสดงให้เห็นไปยัง the DMA ถึงตำแหน่งของ data ใน memory, และหลังจาก data ทั้งหมดถูกส่งถ่าย, the DMA สามารถจากนั้นใช้บิตเหล่านี้เพื่อส่งกลับ time stamp data.

TBAP2: เมื่อ the software ทำให้ descriptor นี้พร้อมใช้งานสำหรับ the DMA (ในขณะที่ the OWN bit ถูกเซ็ตเป็น 1 ใน TDES0), บิตเหล่านี้แสดงให้เห็น the physical address of Buffer 2  เมื่อ a descriptor ring structure ถูกใช้. ถ้า the Second address chained (TDES1 [20]) bit ถูกเซ็ต, address นี้บรรจุ the pointer ไปยัง the physical memory ในที่ๆ the next descriptor มีอยู่. The buffer address pointer ต้องถูกจัดแนวให้ตรง the bus width เฉพาะเมื่อ TDES1 [20] ถูกเซ็ต. (LSBs ถูกละเลยภายใน.)

TTSH: ก่อนที่จะเคลียร์ the OWN bit ใน TDES0, the DMA อัปเดตฟิลด์นี้ด้วย the 32 most significant bits ของ the time stamp ที่จับสำหรับ the corresponding transmit frame (เขียนทับค่าสำหรับ TBAP2). ฟิลด์นี้มี the time stamp เฉพาะถ้า time stamping ถูกทำให้ทำงานสำหรับ frame นี้ (ดู TDES0 bit 25, TTSE) และถ้า the Last segment control bit (LS) ใน the descriptor ถูกเซ็ต.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 16, 2021, 07:13:44 AM
29.6.8 Rx DMA configuration

The Receive DMA engine's reception sequence ถูกแสดงตัวอย่างใน Figure 357 และอธิบายข้างล่างนี้:
1.    The CPU ตั้งค่า Receive descriptors (RDES0-RDES3) และเซ็ต the OWN bit (RDES0[31]).
2.    เมื่อ the SR (ETH_DMAOMR register[1]) bit ถูกเซ็ต, the DMA เข้าสู่ the Run state. ในขณะอยู่ใน the Run state, the
       DMA วนตรวจ the receive descriptor list, พยายามให้ได้มา free descriptors. ถ้า the fetched descriptor ไม่ free (ถูก
       เป็นเจ้าของโดย the CPU), the DMA เข้าสู่ the Suspend state และกระโดดไปยัง Step 9.
3.    The DMA ถอดรหัส the receive data buffer address จาก the acquired descriptors.
4.    Incoming frames จะถูกประมวลผลและวางไว้ใน the acquired descriptor's data buffers.
5.    เมื่อ the buffer เต็มหรือ the frame transfer เสร็จสมบูรณ์, the Receive engine ดึง the next descriptor.
6.    ถ้า the current frame transfer เสร็จสมบูรณ์, the DMA ดำเนินไปยัง step 7. ถ้า the DMA ไม่เป็นเจ้าของ the next fetched
       descriptor และ the frame transfer ไม่เสร็จสมบูรณ์ (EOF ยังไม่ถูกส่งถ่าย), the DMA เซ็ต the Descriptor error bit ใน
       RDES0 (ยกเว้น flushing ถูกปิดการใช้งาน). The DMA ปิด the current descriptor (เคลียร์ the OWN bit) และทำเครื่องหมาย
       มันว่าอยู่ระหว่างทางโดยการเคลียร์ the Last segment (LS) bit ใน the RDES1 value (ทำเครื่องหมายมันเป็น last descriptor
       ถ้า flushing ไม่ถูกปิดการใช้งาน), จากนั้นดำเนินไปยัง step 8. ถ้า the DMA เป็นเจ้าของ the next descriptor แต่ the current
       frame transfer ไม่เสร็จสมบูรณ์, the DMA ปิด the current descriptor ว่าอยู่ระหว่างทางและกลับคืนไปยัง step 4.
7.    ถ้า IEEE 1588 time stamping ถูกเปิดการใช้งาน, the DMA เขียน the time stamp (ถ้ามีให้ใช้งาน) ไปยัง the current
       descriptor's RDES2 and RDES3. จากนั้นจะรับ the received frame's status และเขียน the status word ไปยัง the
       current descriptor's RDES0, พร้อมด้วย the OWN bit ถูกเคลียร์และ the Last segment bit ถูกเซ็ต.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 16, 2021, 09:22:11 AM
8.    The Receive engine เช็ค the latest descriptor's OWN bit. ถ้า the CPU เป็นเจ้าของ the descriptor (OWN bit เป็น 0)
       the Receive buffer unavailable bit (ใน ETH_DMASR register[7]) ถูกเซ็ตและ the DMA Receive engine เข้าสู่ the
       Suspended state (step 9). ถ้า the DMA เป็นเจ้าของ the descriptor, the engine จะกลับไปยัง step 4 และรอ the next
       frame.
9.    ก่อน the Receive engine เข้าสู่ the Suspend state, partial frames ถูกล้างจาก the Receive FIFO (คุณสามารถควบคุมการ
       ล้างโดยใช้ bit 24 ใน the ETH_DMAOMR register).
10.  The Receive DMA ออกจาก the Suspend state เมื่อ a Receive Poll demand ถูกให้หรือการสตาร์ทของ next frame มีให้ใช้
       งานจาก the Receive FIFO. The engine ดำเนินไปยัง step 2 และดึงใหม่ the next descriptor.

The DMA ไม่รับทราบการยอมรับ the status จนกระทั่งมันเสร็จสมบูรณ์ the time stamp write-back และพร้อมที่จะดำเนินการ status เขียนกลับไปยัง the descriptor. ถ้า software เปิดการใช้งาน time stamping ผ่านทาง CSR แล้ว, เมื่อ a valid time stamp value ไม่มีให้ใช้สำหรับ the frame (ตัวอย่างเช่น, เนื่องจาก the receive FIFO เต็มแล้วก่อน the time stamp สามารถถูกเขียนถึงมัน), the DMA จะเขียนทั้งหมดไปยัง RDES2 and RDES3. มิฉะนั้น (นั่นคือ, ถ้า time stamping ไม่ถูกเปิดการใช้งาน), RDES2 and RDES3 ยังคงไม่เปลี่ยนแปลง.

(https://i.imgur.com/87Cr2F0.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on March 17, 2021, 07:11:50 AM
Receive descriptor acquisition

The receive engine พยายามได้มา an extra descriptor เสมอในความคาดหมายของ an incoming frame. Descriptor acquisition ถูกพยายามถ้าเงื่อนไขใด ๆ ต่อไปนี้ถูกทำให้พอใจ:
•    The receive Start/Stop bit (ETH_DMAOMR register[1]) ถูกเซ็ตทันทีหลังจาก the DMA ถูกวางใน the Run state.
•    The data buffer ของ the current descriptor เต็มก่อน the end of the frame ในขณะนี้กำลังส่งถ่าย
•    The controller เสร็จสมบูรณ์ frame reception, แต่ the current receive descriptor ยังไม่ถูกปิด.
•    The receive process ถูกแขวนเพราะว่า a CPU-เป็นเจ้าของ buffer (RDES0[31] = 0) และ a new frame ถูกรับ.
•    A Receive poll demand ถูกปล่อยออก.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 17, 2021, 08:05:05 AM
Receive frame processing

The MAC จะส่งถ่าย the received frames ไปยัง the STM32F107xx memory เฉพาะเมื่อ the frame ผ่าน the address filter และ the frame size มากกว่าหรือเท่ากับ the configurable threshold bytes ที่เซ็ตสำหรับ the Receive FIFO, หรือเมื่อ the complete frame ถูกเขียนไปยัง the FIFO ใน Store-and-forward mode. ถ้า the frame ล้มเหลว the address filtering, มันจะถูกดร็อปใน the MAC block ของมัน (เว้นแต่ Receive All ETH_MACFFR [31] bit ถูกเซ็ต). Frames ที่สั้นกว่า 64 bytes, เนื่องจาก collision หรือ premature termination, สามารถถูกล้างจาก the Receive FIFO. หลังจาก 64 (ขอบเขตที่กำหนดค่าได้) bytes ถูกรับแล้ว, the DMA block เริ่มต้นการส่งถ่าย the frame data ไปยัง the receive buffer ที่ชี้โดย the current descriptor. The DMA เซ็ต the first descriptor (RDES0[9]) หลังจาก the DMA AHB Interface มาเป็นพร้อมรับ a data transfer (ถ้า DMA ไม่กำลังดึง transmit data จาก the memory), เพื่อกั้นเขต the frame. The descriptors ถูกปลดปล่อยเมื่อ the OWN (RDES0[31]) bit ถูกรีเซ็ตเป็น 0, อย่างใดอย่างหนึ่งเนื่องจาก the data buffer เติมหรือเนื่องจาก the last segment of the frame ถูกส่งถ่ายไปยัง the receive buffer. ถ้า the frame ถูกบรรจุใน a single descriptor, ทั้ง the last descriptor (RDES0[8]) และ first descriptor (RDES0[9]) bits ถูกเซ็ต. The DMA ดึง the next descriptor, เซ็ต the last descriptor (RDES0[8]) bit, และปลดปล่อย the RDES0 status bits ใน the previous frame descriptor. จากนั้น the DMA เซ็ต the receive interrupt bit (ETH_DMASR register [6]). ขบวนการเดียวกันจะเกิดขึ้นซ้ำเว้นแต่ the DMA ประสบ a descriptor ที่ป้ายชื่อว่ากำลังถูกเป็นเจ้าของโดย the CPU. หากสิ่งนี้เกิดขึ้น, the receive process เซ็ต the receive buffer unavailable bit (ETH_DMASR register[7]) และจากนั้นเข้าสู่ the Suspend state. ตำแหน่งใน the receive list ถูกเก็บรักษาไว้.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 17, 2021, 09:39:45 AM
Receive process suspended

ถ้า a new receive frame มาถึงในขณะที่ the receive process อยู่ใน Suspend state, the DMA ดึงซ้ำ the current descriptor ใน the STM32F107xx memory. ถ้า the descriptor ตอนนี้ถูกเป็นเจ้าของโดย the DMA, the receive process เข้าสู่ซ้ำ the Run state และสตาร์ท frame reception. ถ้า the descriptor ยังคงถูกเป็นเจ้าของโดย the host, โดยค่าเริ่มต้น, the DMA จะละทิ้ง the current frame ที่ the top of the Rx FIFO และเพิ่ม the missed frame counter. ถ้ามีมากกว่าหนึ่ง frame ถูกเก็บใน the Rx FIFO, the process จะทำซ้ำ. การละทิ้งหรือการล้างของ the frame ที่ the top of the Rx FIFO สามารถที่จะหลีกเลี่ยงโดยการเซ็ต the DMA Operation mode register bit 24 (DFRF). ในเงื่อนไขดังกล่าว, the receive process เซ็ต the receive buffer unavailable status bit และกลับสู่ the Suspend state.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 18, 2021, 07:11:47 AM
Rx DMA descriptors

The descriptor structure ประกอบด้วย four 32-bit words (16 bytes). เหล่านี้แสดงใน Figure 358. The bit descriptions ของ RDES0, RDES1, RDES2 and RDES3 ถูกให้ข้างล่างนี้.

(https://i.imgur.com/KHU6Zyr.png)

•    RDES0: Receive descriptor Word0

RDES0 บรรจุ the received frame status, the frame length และ the descriptor ownership information

(https://i.imgur.com/YTu2TSU.png)

Bit 31 OWN: Own bit
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the descriptor ถูกเป็นเจ้าของโดย the DMA of the MAC Subsystem. เมื่อบิตนี้ถูกรีเซ็ต, มันแสดงให้เห็นว่า the descriptor ถูกเป็นเจ้าของโดย the Host. The DMA เคลียร์บิตนี้อย่างใดอย่างหนึ่งเมื่อมันเสร็จสมบูรณ์ the frame reception หรือเมื่อ the buffers ที่เกี่ยวข้องกับ descriptor นี้เต็ม.

Bit 30 AFM: Destination address filter fail
เมื่อเซ็ต, บิตนี้แสดงให้เห็น a frame ที่ล้มเหลว the DA filter ใน the MAC Core.

Bits 29:16 FL: Frame length
บิตเหล่านี้แสดงให้เห็น the byte length of the received frame ที่ถูกส่งถ่ายไปยัง host memory แล้ว (รวมทั้ง CRC). field นี้ใช้ได้เฉพาะเมื่อ last descriptor (RDES0[8]) ถูกเซ็ตและ descriptor error (RDES0[14]) ถูกรีเซ็ต.
field นี้ใช้ได้เมื่อ last descriptor (RDES0[8]) ถูกเซ็ต. เมื่อ the last descriptor และ error summary bits ไม่ถูกเซ็ต, field นี้แสดงให้เห็น the accumulated number of bytes ที่ถูกส่งถ่ายสำหรับ the current frame.

Bit 15 ES: Error summary
แสดงให้เห็นลอจิก OR ของบิตต่อไปนี้:
RDES0[1]: CRC error
RDES0[3]: Receive error
RDES0[4]: Watchdog timeout
RDES0[6]: Late collision
RDES0[7]: Giant frame (นี้ใช้ไม่ได้เมื่อ RDES0[7] แสดงให้เห็น an IPV4 header checksum error.)
RDES0[11]: Overflow error
RDES0[14]: Descriptor error.
field นี้ใช้ได้เฉพาะเมื่อ the last descriptor (RDES0[8]) ถูกเซ็ต.

Bit 14 DE: Descriptor error
เมื่อเซ็ต, บิตนี้แสดงให้เห็น a frame truncation ที่เกิดจาก a frame ที่ไม่พอดีกับ the current descriptor buffers, และที่ the DMA ไม่ได้เป็นเจ้าของ the next descriptor. The frame ถูกตัดให้สั้นลง.
field นี้ใช้ได้เฉพาะเมื่อ the last descriptor (RDES0[8]) ถูกเซ็ต.

Bit 13 SAF: Source address filter fail
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the SA field of frame ล้มเหลว the SA filter ใน the MAC Core.

Bit 12 LE: Length error
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the actual length of the received frame ไม่ตรงกันกับค่าใน the Length/ Type field. บิตนี้ใช้ได้เฉพาะเมื่อ the Frame type (RDES0[5]) bit ถูกรีเซ็ต.

Bit 11 OE: Overflow error
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the received frame ถูกทำให้เสียหายเนื่องจาก buffer overflow.

Bit 10 VLAN: VLAN tag
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the frame ที่ถูกชี้โดย descriptor นี้คือ a VLAN frame ที่ป้ายชื่อโดย the MAC core.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 18, 2021, 09:32:28 AM
Bit 9 FS: First descriptor
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า descriptor นี้บรรจุ the first buffer of the frame. ถ้า the size of the first buffer เป็น 0, the second buffer บรรจุ the beginning of the frame. ถ้า the size of the second buffer ก็เป็น 0 ด้วย, the next descriptor บรรจุ the beginning of the frame.

Bit 8 LS: Last descriptor
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the buffers ที่ชี้โดย descriptor นี้เป็น the last buffers of the frame.

Bit 7 IPHCE: IPv header checksum error
ถ้า IPHCE ถูกเซ็ต, มันแสดงให้เห็น an error ใน the IPv4 or IPv6 header. error นี้อาจเกิดจากความไม่สอดคล้องกัน Ethernet Type field และ IP header Version field values, a header checksum ไม่ตรงกันใน IPv4, หรือ an Ethernet frame ขาด the expected number of IP header bytes.

Bit 6 LCO: Late collision
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า a late collision ได้เกิดขึ้นในขณะที่กำลังรับ the frame ใน Half-duplex mode.

Bit 5 FT: Frame type
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the Receive frame เป็น an Ethernet-type frame (the LT field มากกว่าหรือเท่ากับ 0x0600). เมื่อบิตนี้ถูกรีเซ็ต, มันแสดงให้เห็นว่า the received frame เป็น an IEEE802.3 frame. บิตนี้ใช้ไม่ได้สำหรับ Runt frames ที่น้อยกว่า 14 bytes.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 18, 2021, 11:06:33 AM
Bit 4 RWT: Receive watchdog timeout
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the Receive watchdog timer หมดเวลาลงแล้วในขณะที่กำลังรับ the current frame และ the current frame ถูกตัดทอนหลังจาก the watchdog timeout.

Bit 3 RE: Receive error
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the RX_ERR signal ถูกถือสิทธิ์ในขณะที่ RX_DV ถูกถือสิทธิ์ในระหว่าง frame reception.

Bit 2 DE: Dribble bit error
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the received frame มี a non-integer multiple of bytes (จำนวนคี่ของสี่บิต). บิตนี้ใช้ได้เฉพาะใน MII mode.

Bit 1 CE: CRC error
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า a cyclic redundancy check (CRC) error เกิดขึ้นบน the received frame. field นี้ใช้ได้เฉพาะเมื่อ the last descriptor (RDES0[8]) ถูกเซ็ต.

Bit 0 PCE: Payload checksum error
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the TCP, UDP or ICMP checksum the core calculated ไม่ตรงกับ the received encapsulated TCP, UDP or ICMP segment's Checksum field. บิตนี้ถูกเซ็ตอีกด้วยเมื่อ the received number of payload bytes ไม่ตรงกับค่าที่แสดงให้เห็นใน the Length field of the encapsulated IPv4 or IPv6 datagram ใน the received Ethernet frame.

Bits 5, 7, and 0 แสดงถึงเงื่อนไขที่อธิบายไว้ใน Table 217.

(https://i.imgur.com/V7wXhzy.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on March 19, 2021, 07:24:04 AM
•    RDES1: Receive descriptor Word1

(https://i.imgur.com/qcmAFYk.png)

Bit 31 DIC: Disable interrupt on completion
เมื่อเซ็ต, บิตนี้ป้องกันการเซ็ต the Status register's RS bit (CSR5[6]) สำหรับ the received frame ที่สิ้นสุดใน the buffer แสดงให้เห็นโดย descriptor นี้. ในทางกลับกัน, นี้จะปิดการใช้งานการถือสิทธิ์ของ the interrupt ไปยัง Host เนื่องจาก RS สำหรับ frame นั้น.

Bits 30:29 Reserved, must be kept at reset value.

Bits 28:16 RBS2: Receive buffer 2 size
บิตเหล่านี้แสดงให้เห็น the second data buffer size, เป็น bytes. The buffer size ต้องเป็นผลคูณของ 4, 8, หรือ 16, ขึ้นอยู่กับ the bus widths (32, 64 หรือ 128, ตามลำดับ), ถึงแม้ว่าค่าของ RDES3 (buffer2 address pointer) ไม่ถูกจัดแนวให้ตรงกับ bus width. ถ้า the buffer size ไม่เป็นผลคุณที่เหมาะสมของ 4, 8 หรือ 16, the resulting behavior ไม่ได้กำหนดไว้. field นี้ใช้ไม่ได้ถ้า RDES1 [14] ถูกเซ็ต.

Bit 15 RER: Receive end of ring
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the descriptor list ถึง final descriptor ของมัน. The DMA กลับคืนไปยัง the base address of the list, สร้าง a descriptor ring.

Bit 14 RCH: Second address chained
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the second address ใน the descriptor คือ the next descriptor address แทนที่จะเป็น the second buffer address. เมื่อบิตนี้ถูกเซ็ต, RBS2 (RDES1[28:16]) เป็นค่า "ที่ไม่ต้องสนใจ". RDES1[15] มีความสำคัญเหนือกว่า RDES1[14].

Bit 13 Reserved, must be kept at reset value.

Bits 12:0 RBS1: Receive buffer 1 size
แสดงให้เห็น the first data buffer size ใน bytes. The buffer size ต้องเป็นผลคูณของ 4, 8, หรือ 16, ขึ้นอยู่กับ the bus widths (32, 64 or 128), ถึงแม้ว่าค่าของ RDES2 (buffer1 address pointer) ไม่ถูกจัดแนว. ถ้า the buffer size ไม่เป็นผลคุณของ 4, 8 หรือ 16, the resulting behavior ไม่ได้กำหนดไว้. ถ้า field นี้เป็น 0, the DMA ละเลย buffer นี้และใช้ Buffer 2 หรือ next descriptor ขึ้นอยู่กับค่าของ RCH (bit 14).
Title: Re: STM32F1 ETHERNET
Post by: tha on March 19, 2021, 08:50:42 AM
•    RDES2: Receive descriptor Word2

RDES2 บรรจุ the address pointer ไปยัง the first data buffer ใน the descriptor, หรือมันบรรจุ time stamp data.

(https://i.imgur.com/B8Gst2l.png)

Bits 31:0 RBAP1 / RTSL: Receive buffer 1 address pointer / Receive frame time stamp low
บิตเหล่านี้มีสองหน้าที่ที่แตกต่างกัน : the application ใช้พวกมันเพื่อแสดงให้เห็นไปยัง the DMA ในที่ๆเก็บ the data ใน memory, และจากนั้นหลังจากการส่งถ่าย the data ทั้งหมด the DMA อาจใช้บิตเหล่านี้เพื่อส่งกลับ time stamp data.
RBAP1 : เมื่อ the software ทำให้ descriptor นี้พร้อมใช้งานสำหรับ the DMA (ในขณะที่ the OWN bit ถูกเซ็ตเป็น 1 ใน RDES0), บิตเหล่านี้แสดงให้เห็น the physical address of Buffer 1. ไม่มีข้อจำกัดบน the buffer address alignment ยกเว้นสำหรับเงื่อนไขต่อไปนี้ : the DMA ใช้ค่าที่กำหนดสำหรับ address generation ของมันเมื่อ the RDES2 value ถูกใช้เพื่อเก็บ the start of frame. โปรดสังเกตว่า the DMA ดำเนินการ a write operation ด้วย the RDES2[3/2/1:0] bits เป็น 0 ในระหว่าง the transfer of the start of frame แต่ the frame data ถูกเลื่อนตาม the actual Buffer address pointer. The DMA จะละเลย RDES2[3/2/1:0] (ตรงกันกับ bus width of 128/64/32) ถ้า the address pointer ชี้ไปยัง a buffer ที่ the middle or last part of the frame ถูกเก็บ.
RTSL : ก่อนที่จะเคลียร์ the OWN bit ใน RDES0, the DMA อัปเดตฟิลด์นี้ด้วย the 32 least significant bits ของ the time stamp ที่จับสำหรับ the corresponding receive frame (เขียนทับค่าสำหรับ RBAP1). ฟิลด์นี้มี the time stamp เฉพาะถ้า time stamping ถูกทำให้ทำงานสำหรับ frame นี้ และถ้า the Last segment control bit (LS) ใน the descriptor ถูกเซ็ต
Title: Re: STM32F1 ETHERNET
Post by: tha on March 19, 2021, 10:17:10 AM
•    RDES3: Receive descriptor Word3

RDES3 บรรจุ the address pointer อย่างใดอย่างหนึ่งไปยัง the second buffer of the descriptor หรือ the next descriptor, หรือมันบรรจุ time stamp data.

(https://i.imgur.com/PiTG3Ce.png)

Bits 31:0 RBAP2 / RTSH: Receive buffer 2 address pointer (next descriptor address) / Receive frame time stamp high
บิตเหล่านี้มีสองหน้าที่ที่แตกต่างกัน : the application ใช้พวกมันเพื่อแสดงให้เห็นไปยัง the DMA ตำแหน่งที่เก็บ the data ใน memory, และจากนั้นหลังจากการส่งถ่าย the data ทั้งหมด the DMA อาจใช้บิตเหล่านี้เพื่อส่งกลับ time stamp data.
RBAP2 :  เมื่อ the software ทำให้ descriptor นี้พร้อมใช้งานสำหรับ the DMA (ในขณะที่ the OWN bit ถูกเซ็ตเป็น 1 ใน RDES0), บิตเหล่านี้แสดงให้เห็น the physical address of Buffer 2. เมื่อ a descriptor ring structure ถูกใช้. ถ้า the Second address chained (RDES1 [20]) bit ถูกเซ็ต, address นี้บรรจุ the pointer ไปยัง the physical memory ในที่ๆ the next descriptor ปรากฎ. ถ้า RDES1 [24] ถูกเซ็ต, the buffer (next descriptor) address pointer ต้องเป็น bus width-aligned (RDES3[3, 2, or 1:0] = 0, ตรงกันกับ a bus width of 128, 64 or 32. LSBs ถูกละเลยภายใน.)
อย่างไรก็ตาม, เมื่อ RDES1 [24] ถูกรีเซ็ต, ไม่มีข้อจำกัดบน the RDES3 value, ยกเว้นสำหรับเงื่อนไขต่อไปนี้: the DMA ใช้ค่าที่กำหนดสำหรับ buffer address generation ของมันเมื่อ the RDES3 value ถูกใช้เก็บ the start of frame. The DMA จะละเลย RDES2[3/2/1:0] (ตรงกันกับ bus width of 128/64/32) ถ้า the address pointer ชี้ไปยัง a buffer ที่ the middle or last part of the frame ถูกเก็บ.
RTSH : ก่อนที่จะเคลียร์ the OWN bit ใน RDES0, the DMA อัปเดตฟิลด์นี้ด้วย the 32 most significant bits ของ the time stamp ที่จับสำหรับ the corresponding receive frame (เขียนทับค่าสำหรับ RBAP2). ฟิลด์นี้มี the time stamp เฉพาะถ้า time stamping ถูกทำให้ทำงานสำหรับ frame นี้ และถ้า the Last segment control bit (LS) ใน the descriptor ถูกเซ็ต
Title: Re: STM32F1 ETHERNET
Post by: tha on March 20, 2021, 07:16:40 AM
29.6.9 DMA interrupts

Interrupts สามารถถูกสร้างจากผลของ events ต่างๆ. The ETH_DMASR register บรรจุ the bits ทั้งหมดที่อาจทำให้เกิด an interrupt. The ETH_DMAIER register บรรจุ an enable bit สำหรับแต่ละของ the events ที่สามารถทำให้เกิด an interrupt.

มีสองกลุ่มของ interrupts, Normal และ Abnormal, ดังอธิบายใน the ETH_DMASR register. Interrupts ถูกเคลียร์โดยการเขียน a 1 ไปยัง the corresponding bit position. เมื่อ the enabled interrupts ทั้งหมดภายในกลุ่มถูกเคลียร์, the corresponding summary bit จะถูกเคลียร์. ถ้า the MAC core เป็นสาเหตุของการถือสิทธิ์ของ the interrupt, จากนั้นอันหนึ่งอันใด the TSTS หรือ PMTS bits ใน the ETH_DMASR register ถูกเซ็ต high.

Interrupts ไม่เข้าคิวและถ้า the interrupt event เกิดขึ้นก่อน the driver ตอบสนองต่อมัน, ไม่มี interrupts เพิ่มเติมถูกสร้างขึ้น. ตัวอย่างเช่น, the Receive Interrupt bit (ETH_DMASR register [6]) แสดงให้เห็นว่าหนึ่งหรือมากกว่าหนึ่ง frames ได้ถูกส่งถ่ายไปยัง the STM32F107xx buffer แล้ว. The driver ต้องสแกน descriptors ทั้งหมด, จาก the last recorded position ไปยัง the first one ที่เป็นเจ้าของโดย the DMA.

An interrupt ถูกสร้างขึ้นเพียงครั้งเดียวสำหรับหลาย events ที่พร้อมกัน. The driver ต้องสแกน the ETH_DMASR register สำหรับสาเหตุของ the interrupt. The interrupt ไม่ถูกสร้างขึ้นอีกครั้งเว้นแต่ a new interrupting event เกิดขึ้น, หลังจาก the driver ได้เคลียร์ the appropriate bit ใน the ETH_DMASR register. ตัวอย่างเช่น, the controller สร้าง a Receive interrupt (ETH_DMASR register[6]) และ the driver เริ่มต้นการอ่าน the ETH_DMASR register. ต่อไป, receive buffer unavailable (ETH_DMASR register[7]) เกิดขึ้น. The driver เคลียร์ the Receive interrupt. ถึงกระนั้น, a new interrupt ถูกสร้างขึ้น, เนื่องจาก the active หรือ pending Receive buffer unavailable interrupt.

(https://i.imgur.com/52QCJ9v.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on March 20, 2021, 09:42:44 AM
29.7 Ethernet interrupts

The Ethernet controller มี two interrupt vectors: หนึ่งอุทิศให้กับ normal Ethernet operations และอีกตัว, ใช้เฉพาะสำหรับ the Ethernet wakeup event (ด้วย wakeup frame หรือ Magic Packet detection) เมื่อมันถูกแม็ปบน EXTI lIne19.

The first Ethernet vector ถูกสงวนไว้สำหรับ interrupts ที่สร้างขึ้นโดย the MAC และ the DMA ดังแสดงรายการใน the MAC interrupts และ DMA interrupts sections.

The second vector ถูกสงวนไว้สำหรับ interrupts ที่สร้างขึ้นโดย the PMT บน wakeup events. การแม็ปของ a wakeup event บน EXTI line19 เป็นสาเหตุให้ the STM32F107xx ออกจาก the low-power mode, และสร้าง an interrupt.

เมื่อ an Ethernet wakeup event ที่แม็ปบน EXTI Line19 เกิดขึ้นและ the MAC PMT interrupt ถูกเปิดการใช้งานและ the EXTI Line19 interrupt, พร้อมด้วยการตรวจพบบน rising edge, ถูกเปิดการใช้งานด้วย, ทั้งสอง interrupts ถูกสร้างขึ้น.

A watchdog timer (ดู ETH_DMARSWTR register) ถูกให้สำหรับการควบคุมที่ยืดหยุ่นของ the RS bit (ETH_DMASR register). เมื่อ watchdog timer นี้ถูกโปรแกรมด้วยค่าที่ไม่ใช่ศูนย์, มันได้รับทำให้ทำงานทันทีที่ the RxDMA เสร็จสมบูรณ์ a transfer of a received frame ไปยัง system memory โดยไม่มีการถือสิทธิ์ the Receive Status เนื่องจากมันไม่ถูกเปิดการใช้งานใน the corresponding Receive descriptor (RDES1[31]). เมื่อ timer นี้วิ่งเลยจากค่าที่โปรแกรมไว้, the RS bit ถูกเซ็ตและ the interrupt ถูกถือสิทธิ์ถ้า the corresponding RIE ถูกเปิดการใช้งานใน the ETH_DMAIER register. timer นี้ถูกปิดการใช้งานก่อนมันจะวิ่งเลย, เมื่อ a frame ถูกส่งถ่ายไปยัง memory และ the RS ถูกเซ็ตเนื่องจากมันถูกเปิดการใช้งานสำหรับ descriptor นั้น.

Note : การอ่าน the PMT control and status register จะเคลียร์โดยอัตโนมัติ the Wakeup Frame Received และ Magic
           Packet Received PMT interrupt flags. อย่างไรก็ตาม, เนื่องจาก the registers สำหรับ flags เหล่านี้อยู่ใน the CLK_RX
           domain, อาจจะมี a significant delay ก่อนอัปเดตนี้ถูกมองเห็นโดย the firmware. The delay จะยาวเป็นพิเศษเมื่อ the RX
           clock ช้า (ใน 10 Mbitmode) และเมื่อ the AHB bus เป็น high-frequency.
           เนื่องจาก interrupt requests จาก the PMT ไปยัง the CPU ขึ้นอยู่กับ the same registers ใน the CLK_RX domain,
           the CPU อาจเรียกอย่างปลอมๆ the interrupt routine ครั้งที่สองแม้หลังจากการอ่าน PMT_CSR. ดังนั้น, มันอาจมีความจำเป็นที่
           the firmware จะวนตรวจ the Wakeup Frame Received และd Magic Packet Received bits และออกจาก the
           interrupt service routine เฉพาะเมื่อพวกมันถูกพบว่าเป็น '0'.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 21, 2021, 07:17:01 AM
29.8 Ethernet register descriptions

The peripheral registers สามารถถูกเข้าถึงโดย bytes (8-bit), half-words (16-bit) or words (32-bits).

29.8.1 MAC register description

Ethernet MAC configuration register (ETH_MACCR)

Address offset: 0x0000
Reset value: 0x0000 8000

The MAC configuration register คือ the operation mode register of the MAC. มันสร้าง receive and transmit operating modes.

(https://i.imgur.com/8sI82oo.png)

Bits 31:24 Reserved, must be kept at reset value.

Bit 23 WD: Watchdog disable
เมื่อบิตนี้ถูกเซ็ต, the MAC ปิดการใช้งาน the watchdog timer บน the receiver, และสามารถรับ frames ได้มากถึง 16 384 bytes.
เมื่อบิตนี้ถูกรีเซ็ต, the MAC ยอมให้ไม่มากกว่า 2 048 bytes ของ the frame ถูกรับและตัด bytes ใดๆที่รับหลังจากนั้น.

Bit 22 JD: Jabber disable
เมื่อบิตนี้ถูกเซ็ต, the MAC ปิดการใช้งาน the jabber timer บน the transmitter, และสามารถส่งถ่าย frames ได้มากถึง 16 384 bytes.
เมื่อบิตนี้ถูกรีเซ็ต, the MAC จะปิด the transmitter ถ้า the application ส่งออกมากกว่า 2 048 bytes ของ data ในระหว่าง transmission.

Bits 21:20 Reserved, must be kept at reset value.

Bits 19:17 IFG: Interframe gap
บิตเหล่านี้ควบคุม the minimum interframe gap ระหว่าง frames ในระหว่าง transmission.
     000: 96 bit times
     001: 88 bit times
     010: 80 bit times
     ....
     111: 40 bit times
Note: ใน Half-duplex mode, the minimum IFG สามารถถูกกำหนดค่าเป็น 64 bit times (IFG = 100) เท่านั้น. ค่าที่ต่ำกว่าจะไม่ถูกพิจารณา.

Bit 16 CSD: Carrier sense disable
เมื่อเซ็ต high, บิตนี้ทำให้ the MAC transmitter ไม่สนใจ the MII CRS signal ในระหว่าง frame transmission ใน Half-duplex mode. ไม่มี error ถูกสร้างขึ้นเนื่องจาก Loss of Carrier หรือ No Carrier ในระหว่าง transmission ดังกล่าว.
เมื่อบิตนี้เป็น low, the MAC transmitter สร้างขึ้น errors ดังกล่าวเนื่องจาก Carrier Sense และแม้กระทั่งยกเลิก the transmissions.
Bit 15 Reserved, must be kept at reset value.

Bit 14 FES: Fast Ethernet speed
แสดงให้เห็น the speed ใน Fast Ethernet (MII) mode:
     0: 10 Mbit/s
     1: 100 Mbit/s

Bit 13 ROD: Receive own disable
เมื่อบิตนี้ถูกเซ็ต, the MAC ปิดการใช้งาน the reception of frames ใน Half-duplex mode.
เมื่อบิตนี้ถูกรีเซ็ต, the MAC จะรับ packets ทั้งหมดที่ถูกให้โดย the PHY ในขณะการส่ง.
บิตนี้ใช้ไม่ได้ถ้า the MAC กำลังทำงานใน Full-duplex mode.

Bit 12 LM: Loopback mode
เมื่อบิตนี้ถูกเซ็ต, the MAC ทำงานใน loopback mode ที่ the MII. The MII รับ clock input (RX_CLK) ที่ต้องการสำหรับ the loopback เพื่อทำงานอย่างถูกต้อง, เนื่องจาก the transmit clock ไม่ได้ looped-back ภายใน.

Bit 11 DM: Duplex mode
เมื่อบิตนี้ถูกเซ็ต, the MAC ทำงานใน a Full-duplex mode ที่มันสามารถ transmit และ receive พร้อมกัน.

Bit 10 IPCO: IPv4 checksum offload
เมื่อเซ็ต, บิตนี้เปิดการใช้งาน IPv4 checksum เช็คสำหรับ received frame payloads TCP/UDP/ICMP headers. เมื่อบิตนี้ถูกรีเซ็ต, the checksum offload function ใน the receiver ถูกปิดการใช้งานและ the corresponding PCE และ IP HCE status bits (ดู Table 214) จะถูกเคลียร์เสมอ.

Bit 9 RD: Retry disable
เมื่อบิตนี้ถูกเซ็ต, the MAC พยายามเพียง 1 transmission. เมื่อ a collision เกิดขึ้นบน the MII, the MAC ไม่สนใจ the current frame transmission และรายงาน a Frame Abort ด้วย excessive collision error ใน the transmit frame status.
เมื่อบิตนี้ถูกรีเซ็ต, the MAC พยายยามลองใหม่ตามการตั้งค่าของ BL.
Note: บิตนี้ใช้ได้เฉพาะใน the Half-duplex mode.

Bit 8 Reserved, must be kept at reset value.

Bit 7 APCS: Automatic pad/CRC stripping
เมื่อบิตนี้ถูกเซ็ต, the MAC ปอก the Pad/FCS field บน incoming frames เฉพาะถ้า the length's field value น้อยกว่าหรือเท่ากับ 1 500 bytes. received frames ทั้งหมดที่มี length field มากกว่าหรือเท่ากับ 1 501 bytes จะถูกส่งผ่านไปยัง the application โดยไม่มีการปอก the Pad/FCS field.
เมื่อบิตนี้ถูกรีเซ็ต, the MAC ส่งผ่าน incoming frames ทั้งหมดโดยไม่ได้แก้ไข.

Bits 6:5 BL: Back-off limit
The Back-off limit กำหนด the random integer number (r) ของ slot time delays (4 096 bit ครั้งสำหรับ 1000 Mbit/s และ 512 bit ครั้งสำหรับ 10/100 Mbit/s) the MAC รอก่อนกำหนดเวลาใหม่ a transmission พยายามในระหว่างลองอีกครั้งหลังจาก a collision.
Note: บิตนี้ใช้ได้เฉพาะกับ Half-duplex mode.
     00: k = min (n, 10)
     01: k = min (n, 8 )
     10: k = min (n, 4)
     11: k = min (n, 1),
โดยที่ n = พยายามส่งซ้ำ. The random integer r รับค่าในย่าน 0 ≤ r < 2^k
Title: Re: STM32F1 ETHERNET
Post by: tha on March 21, 2021, 09:21:48 AM
Bit 4 DC: Deferral check
เมื่อบิตนี้ถูกเซ็ต, the deferral check function ถูกเปิดการใช้งานใน the MAC. The MAC ปล่อยออก a Frame Abort status, พร้อมกับ the excessive deferral error bit เซ็ตใน the transmit frame status เมื่อ the transmit state machine ถูกเลื่อนออกไปมากกว่า 24 288 bit ครั้งใน 10/100-Mbit/s mode. การยืดเวลาเริ่มต้นเมื่อ the transmitter พร้อมที่จะส่ง, แต่ถูกขัดขวางเนื่องจาก an active CRS (carrier sense) signal บน the MII. Defer time จะไม่สะสม. ถ้า the transmitter เลื่อนไป 10 000 bit ครั้ง, จากนั้นส่ง, ชนกัน, ถอยออก, และเลื่อนออกไปอีกครั้งหลังจากเสร็จสมบูรณ์ของการถอยออก, the deferral timer รีเซ็ตเป็น 0 และรีสตาร์ท.
เมื่อบิตนี้ถูกรีเซ็ต, the deferral check function ถูกปิดการใช้งานและ the MAC จะเลื่อนไปจนกว่า the CRS signal ไม่ทำงาน. บิตนี้ใช้ได้เฉพาะใน Half-duplex mode.

Bit 3 TE: Transmitter enable
เมื่อบิตนี้ถูกเซ็ต, the transmit state machine of the MAC ถูกเปิดการใช้งานสำหรับ transmission บน the MII. เมื่อบิตนี้ถูกรีเซ็ต, the MAC transmit state machine ถูกปิดการใช้งานหลังจากการเสร็จสมบูรณ์ของ the transmission of the current frame, และจะไม่ส่ง frames ต่อไปใดๆ.

Bit 2 RE: Receiver enable
เมื่อบิตนี้ถูกเซ็ต, the receiver state machine of the MAC ถูกเปิดการใช้งานสำหรับ receiving frames จาก the MII. เมื่อบิตนี้ถูกรีเซ็ต, the MAC receive state machine ถูกปิดการใช้งานหลังจากการเสร็จสมบูรณ์ของ the reception of the current frame, และจะไม่รับ frames ต่อไปใดๆจาก the MII.

Bits 1:0 Reserved, must be kept at reset value.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 21, 2021, 12:30:21 PM
Ethernet MAC frame filter register (ETH_MACFFR)

Address offset: 0x0004
Reset value: 0x0000 0000

The MAC frame filter register บรรจุ the filter controls สำหรับ receiving frames. บางส่วนของ the controls จาก register นี้ไปยัง the address check block of the MAC, ซึ่งดำเนินการ the first level of address filtering. The second level of filtering ถูกดำเนินการบน the incoming frame, ขึ้นอยู่กับ controls อื่นๆอย่างเช่นผ่าน bad frames และผ่าน control frames.

(https://i.imgur.com/GSXq5Gt.png)

Bit 31 RA: Receive all
เมื่อบิตนี้ถูกเซ็ต, the MAC receiver ส่งผ่าน received frames ทั้งหมดไปยัง the application, โดยไม่คำนึงถึงว่าพวกมันผ่าน the address filter หรือไม่. ผลของ the SA/DA filtering ถูกอัปเดต (ผ่านหรือล้มเหลว) ใน the corresponding bits ใน the receive status word. เมื่อบิตนี้ถูกรีเซ็ต, the MAC receiver ส่งผ่านไปยัง the application เฉพาะ frames เหล่านั้นที่ผ่าน the SA/DA address filter.

Bits 30:11 Reserved, must be kept at reset value.

Bit 10 HPF: Hash or perfect filter
เมื่อบิตนี้ถูกเซ็ตและถ้า the HM หรือ HU bit ถูกเซ็ต, the address filter ผ่าน frames ที่ตรงกับอย่างใดอย่างหนึ่ง the perfect filtering หรือ the hash filtering.
เมื่อบิตนี้ถูกเคลียร์และถ้า the HU หรือ HM bit ถูกเซ็ต, เฉพาะ frames ที่ตรงกับ the Hash filter เท่านั้นที่จะถูกผ่าน.

Bit 9 SAF: Source address filter
The MAC core เปรียบเทียบ the SA field ของ the received frames ด้วยค่าที่ถูกโปรแกรมใน the enabled SA registers. ถ้าการเปรียบเทียบตรงกัน, จากนั้น the SAMatch bit ใน the RxStatus word ถูกเซ็ต high. เมื่อบิตนี้ถูกเซ็ต high และ the SA filter ล้มเหลว, the MAC จะดร็อป the frame. เมื่อบิตนี้ถูกรีเซ็ต, the MAC core ส่งต่อ the received frame ไปยัง the application. นอกจากนี้ยังส่งต่อ the updated SA Match bit ใน RxStatus ขึ้นอยู่กับ the SA address comparison.

Bit 8 SAIF: Source address inverse filtering
เมื่อบิตนี้ถูกเซ็ต, the address check block ทำงานใน inverse filtering mode สำหรับ the SA address comparison. The frames ซึ่ง SA ตรงกับ the SA registers จะถูกทำเครื่องหมายว่าล้มเหลว the SA address filter.
เมื่อบิตนี้ถูกรีเซ็ต, frames ซึ่ง SA ไม่ตรงกับ the SA registers จะถูกทำเครื่องหมายว่าล้มเหลว the SA address filter.

Bits 7:6 PCF: Pass control frames
บิตเหล่านี้ควบคุมการส่งต่อของ all control frames (รวมถึง unicast and multicast PAUSE frames). โปรดทราบว่าการประมวลผลของ PAUSE control frames ขึ้นอยู่กับ RFCE เท่านั้นใน Flow Control Register[2].
     00 or 01: MAC ป้องกันไม่ให้ all control frames จากการถึง the application
     10: MAC ส่งต่อ all control frames ไปยัง application ถึงแม้ว่าพวกมันจะล้มเหลว the address filter
     11: MAC ส่งต่อ control frames ที่ผ่าน the address filter.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 21, 2021, 01:11:06 PM
Bit 5 BFD: Broadcast frames disable
เมื่อบิตนี้ถูกเซ็ต, the address filters จะกรอง all incoming broadcast frames.
เมื่อบิตนี้ถูกรีเซ็ต, the address filters จะผ่าน all received broadcast frames.

Bit 4 PAM: Pass all multicast
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า all received frames ที่มี a multicast destination address (บิตแรกใน the destination address field เป็น '1') ถูกผ่าน.
เมื่อรีเซ็ต, การกรองของ multicast frame ขึ้นอยู่กับ the HM bit.

Bit 3 DAIF: Destination address inverse filtering
เมื่อบิตนี้ถูกเซ็ต, the address check block ทำงานใน inverse filtering mode สำหรับ the DA address comparison สำหรับทั้ง unicast and multicast frames.
เมื่อรีเซ็ต, normal filtering of frames ถูกดำเนินการ.

Bit 2 HM: Hash multicast
เมื่อเซ็ต, MAC ดำเนินการ destination address filtering ของ received multicast frames สอดคล้องกับ the hash table.
เมื่อรีเซ็ต, the MAC ดำเนินการ a perfect destination address filtering สำหรับ multicast frames, นั่นคือ, มันจะเปรียบเทียบ the DA field ด้วยค่าที่ถูกโปรแกรมใน DA registers.

Bit 1 HU: Hash unicast
เมื่อเซ็ต, MAC ดำเนินการ destination address filtering ของ received unicast frames สอดคล้องกับ the hash table.
เมื่อรีเซ็ต, the MAC ดำเนินการ a perfect destination address filtering สำหรับ unicast frames, นั่นคือ, มันจะเปรียบเทียบ the DA field ด้วยค่าที่ถูกโปรแกรมใน DA registers.

Bit 0 PM: Promiscuous mode
เมื่อบิตนี้ถูกเซ็ต, the address filters ผ่าน all incoming frames โดยไม่คำนึงถึง destination หรือ source address ของมัน. The SA/DA filter fails status bits ใน the receive status word ถูกเคลียร์เสมอเมื่อ PM ถูกเซ็ต.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 22, 2021, 07:35:44 AM
Ethernet MAC hash table high register (ETH_MACHTHR)

Address offset: 0x0008
Reset value: 0x0000 0000

The 64-bit Hash table ถูกใช้สำหรับ group address filtering. สำหรับ hash filtering, สิ่งที่บรรจุภายในของ the destination address ใน the incoming frame ถูกส่งผ่านไปยัง the CRC logic, และ the upper 6 bits ใน the CRC register ถูกใช้เพื่อชี้สิ่งที่บรรจุภายในของ the Hash table. CRC นี้คือ a 32-bit value ที่เข้ารหัสโดยพหุนามต่อไปนี้ (สำหรับรายละเอียดเพิ่มเติมโปรดดู Section 29.5.3):

(https://i.imgur.com/gVwCsAr.png)

The most significant bit กำหนด the register ที่ถูกใช้ (hash table high/hash table low), และ 5 bits ที่เหลือกำหนดซึ่ง bit ที่อยู่ภายใน the register. A hash value ของ 0b0 0000 เลือก bit 0 ใน the selected register, และค่าของ 0b1 1111 เลือก bit 31 ใน the selected register.

ตัวอย่างเช่น, ถ้า the DA ของ the incoming frame ถูกรับเป็น 0x1F52 419C B6AF (0x1F คือ the first byte ที่รับบน the MII interface), จากนั้น the internally calculated 6-bit Hash value คือ 0x2C และ the HTH register bit[12] ถูกตรวจสอบสำหรับการกรอง. ถ้า the DA ของ the incoming frame ถูกรับเป็น 0xA00A 9800 0045, จากนั้น the calculated 6-bit Hash value คือ 0x07 และ the HTL register bit[7] ถูกตรวจสอบสำหรับการกรอง.

ถ้า the corresponding bit value ใน the register เป็น 1, the frame จะถูกยอมรับ. มิฉะนั้น, มันจะถูกปฏิเสธ. ถ้า the PAM (ผ่านทุก multicast) bit ถูกเซ็ตใน the ETH_MACFFR register, จากนั้น all multicast frames ถูกยอมรับโดยไม่คำนึงถึง the multicast hash values.

The Hash table high register บรรจุ the higher 32 bits of the multicast Hash table

(https://i.imgur.com/1PoJREU.png)

Bits 31:0 HTH: Hash table high
field นี้บรรจุ the upper 32 bits of Hash table.

Ethernet MAC hash table low register (ETH_MACHTLR)

Address offset: 0x000C
Reset value: 0x0000 0000

The Hash table low register บรรจุ the lower 32 bits of the multi-cast Hash table.

(https://i.imgur.com/DztEPYd.png)

Bits 31:0 HTL: Hash table low
field นี้บรรจุ the lower 32 bits of the Hash table
Title: Re: STM32F1 ETHERNET
Post by: tha on March 22, 2021, 09:35:35 AM
Ethernet MAC MII address register (ETH_MACMIIAR)

Address offset: 0x0010
Reset value: 0x0000 0000

The MII address register ควบคุม the management หมุนรอบไปยัง the external PHY ผ่านทาง the management interface.

(https://i.imgur.com/UBk1aDJ.png)

Bits 31:16 Reserved, must be kept at reset value.

Bits 15:11 PA: PHY address
field นี้จะบอกซึ่ง the 32 possible PHY devices กำลังถูกเข้าถึง

Bits 10:6 MR: MII register
บิตเหล่านี้เลือก the desired MII register ใน the selected PHY device.

Bit 5 Reserved, must be kept at reset value.

Bits 4:2 CR: Clock range
The CR clock range selection กำหนด the HCLK frequency และถูกใช้เพื่อตัดสิน the frequency of the MDC clock:
Selection HCLK MDC Clock
     000 60-72 MHz HCLK/42
     001 Reserved -
     010 20-35 MHz HCLK/16
     011 35-60 MHz HCLK/26
     100, 101, 110, 111 Reserved -

Bit 1 MW: MII write
เมื่อเซ็ต, บิตนี้บอก the PHY ว่านี้จะเป็น a Write operation โดยใช้ the MII Data register. ถ้าบิตนี้ไม่ถูกเซ็ต, นี้จะเป็น a Read operation, โดยวาง the data ใน the MII Data register.

Bit 0 MB: MII busy
บิตนี้ควรอ่านได้ a logic 0 ก่อนการเขียนไปยัง ETH_MACMIIAR and ETH_MACMIIDR. บิตนี้ต้องถูกรีเซ็ตเป็น 0 อีกด้วยในระหว่างการเขียนไปยัง ETH_MACMIIAR. ในระหว่าง a PHY register access, บิตนี้ถูกเซ็ตเป็น 0b1 โดย the application เพื่อแสดงให้เห็นว่า a read หรือ write access กำลังดำเนินการอยู่. ETH_MACMIIDR (MII Data) ควรถูกเก็บว่าใช้ได้จนกว่าบิตนี้จะถูกเคลียร์โดย the MAC ในระหว่าง a PHY Write operation. The ETH_MACMIIDR ใช้ไม่ได้จนกว่าาบิตนี้จะถูกเคลียร์โดย the MAC ในระหว่าง a PHY Read operation. The ETH_MACMIIAR (MII Address) ไม่ควรถูกเขียนถึงจนกว่าาบิตนี้จะถูกเคลียร์.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 22, 2021, 10:31:07 AM
Ethernet MAC MII data register (ETH_MACMIIDR)

Address offset: 0x0014
Reset value: 0x0000 0000

The MAC MII Data register เก็บ write data ที่จะถูกเขียนไปยัง the PHY register ที่อยู่ที่ the address ที่ระบุใน ETH_MACMIIAR. ETH_MACMIIDR ยังเก็บ read data อีกด้วยจาก the PHY register ที่อยู่ที่ the address ที่ระบุโดย ETH_MACMIIAR.

(https://i.imgur.com/U2O5xpA.png)

Bits 31:16 Reserved, must be kept at reset value.

Bits 15:0 MD: MII data
นี้จะบรรจุ the 16-bit data value ที่อ่านจาก the PHY หลังจาก a Management Read operation, หรือ the 16-bit data value ที่จะถูกเขียนไปยัง the PHY ก่อน a Management Write operation.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 23, 2021, 07:16:26 AM
Ethernet MAC flow control register (ETH_MACFCR)

Address offset: 0x0018
Reset value: 0x0000 0000

The Flow control register ควบคุม the generation and reception ของ the control (Pause Command) frames โดย the MAC. การเขียนไปยัง a register โดยที่ the Busy bit เซ็ตเป็น '1' เป็นสาเหตุให้ the MAC สร้าง a pause control frame. The fields of the control frame ถูกเลือกตามที่ระบุใน the 802.3x specification, และ the Pause Time value จาก register นี้ถูกใช้ใน the Pause Time field of the control frame. The Busy bit ยังคงเซ็ตจนกระทั่ง the control frame ถูกส่งถ่ายไปบน the cable. The Host ต้องทำให้แน่ใจว่า the Busy bit ถูกเคลียร์ก่อนการเขียนไปยัง the register.

(https://i.imgur.com/156YejU.png)

Bits 31:16 PT: Pause time
field นี้เก็บค่าที่จะถูกใช้ใน the Pause Time field ใน the transmit control frame. ถ้า the Pause Time bits ถูกกำหนดค่าให้ double-synchronized กับ the MII clock domain, จากนั้น consecutive write operations ไปยัง register นี้ควรถูกดำเนินการเฉพาะหลังจากอย่างน้อย 4 clock cycles ใน the destination clock domain.

Bits 15:8 Reserved, must be kept at reset value.

Bit 7 ZQPD: Zero-quanta pause disable
เมื่อเซ็ต, บิตนี้ปิดการใช้งาน the automatic generation of Zero-quanta pause control frames บนการยกเลิกถือสิทธิ์ของ the flow-control signal จาก the FIFO layer.
เมื่อบิตนี้ถูกรีเซ็ต, normal operation โดยมี automatic Zero-quanta pause control frame generation ถูกเปิดการใช้งาน.

Bits 5:4 PLT: Pause low threshold
field นี้กำหนดค่าขีดจำกัดของ the Pause timer ที่ซึ่ง the Pause frame ถูกส่งใหม่โดยอัตโนมัติ. ค่าขีดจำกัดควรน้อยกว่า the Pause Time ที่กำหนดค่าใน bits[31:16]. ตัวอย่างเช่น, ถ้า PT = 100H (256 slot-times), และ PLT = 01, จากนั้น a second PAUSE frame จะถูกส่งโดยอัตโนมัติถ้าเริ่มต้นที่ 228 (256 – 28) slot-times หลังจาก the first PAUSE frame ถูกส่ง.
     การเลือกขีดจำกัด
     00 Pause time ลบ 4 slot times
     01 Pause time ลบ 28 slot times
     10 Pause time ลบ 144 slot times
     11 Pause time ลบ 256 slot times
Slot time ถูกกำหนดเป็นเวลาที่ใช้ในการส่ง 512 bits (64 bytes) บน the MII interface.

Bit 3 UPFD: Unicast pause frame detect
เมื่อบิตนี้ถูกเซ็ต, the MAC ตรวจพบ the Pause frames ที่มี the station's unicast address ที่ระบุใน the ETH_MACA0HR and ETH_MACA0LR registers, เพื่อการตรวจพบ Pause frames ที่มี the unique multicast address.
เมื่อบิตนี้ถูกรีเซ็ต, the MAC ตรวจพบเฉพาะ a Pause frame ที่มี the unique multicast address ที่ระบุใน the 802.3x standard

Bit 2 RFCE: Receive flow control enable
เมื่อบิตนี้ถูกเซ็ต, the MAC ถอดระหัส the received Pause frame และปิดการใช้งาน transmitter ของมันเป็นเวลา a specified (Pause Time) time.
เมื่อบิตนี้ถูกรีเซ็ต, the decode function of the Pause frame ถูกปิดการใช้งาน.

Bit 1 TFCE: Transmit flow control enable
ใน Full-duplex mode, เมื่อบิตนี้ถูกเซ็ต, the MAC เปิดการใช้งาน the flow control operation ไปยัง transmit Pause frames. เมื่อบิตนี้ถูกรีเซ็ต, the flow control operation ใน the MAC ถูกปิดการใช้งาน, และ the MAC จะไม่ส่ง Pause frames ใดๆ.
ใน Half-duplex mode, เมื่อบิตนี้ถูกเซ็ต, the MAC เปิดการใช้งาน the back-pressure operation.เมื่อบิตนี้ถูกรีเซ็ต, the back pressure feature ถูกปิดการใช้งาน.

Bit 0 FCB/BPA: Flow control busy/back pressure activate
บิตนี้เริ่มต้น a Pause Control frame ใน Full-duplex mode และทำให้ทำงาน the back pressure function ใน Half-duplex mode ถ้า TFCE bit ถูกเซ็ต.
ใน Full-duplex mode, บิตนี้ควรถูกอ่านเป็น 0 ก่อนการเขียนไปยัง the Flow control register. เพื่อเริ่มต้น a Pause control frame, the Application ต้องเซ็ตบิตนี้เป็น 1. ในระหว่าง a transfer of the Control frame, บิตนี้ยังคงถูกเซ็ตเพื่อแจ้งให้ทราบว่า a frame transmission กำลังดำเนินการอยู่. หลังจาก completion of the Pause control frame transmission, the MAC รีเซ็ตบิตนี้เป็น 0. The Flow control register ไม่ควรถูกเขียนถึงจนกว่าบิตนี้จะถูกเคลียร์.
ใน Half-duplex mode, เมื่อบิตนี้ถูกเซ็ต (และ TFCE ถูกเซ็ต), back pressure ถูกถือสิทธิ์โดย the MAC core. ในระหว่าง back pressure, เมื่อ the MAC รับ a new frame, the transmitter สตาร์ทการส่ง a JAM pattern ทำให้เกิด a collision. เมื่อ the MAC ถูกกำหนดค่าเป็น Full-duplex mode, the BPA ถูกปิดการใช้งานโดยอัตโนมัติ.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 23, 2021, 09:22:46 AM
Ethernet MAC VLAN tag register (ETH_MACVLANTR)

Address offset: 0x001C
Reset value: 0x0000 0000

The VLAN tag register บรรจุ the IEEE 802.1Q VLAN Tag เพื่อระบุ the VLAN frames. The MAC เปรียบเทียบ the 13th and 14th bytes ของ the receiving frame (Length/Type) กับ 0x8100, และ 2 bytes ที่ตามมาถูกเปรียบเทียบกับ the VLAN tag; ถ้าการตรงกันเกิดขึ้น, the received VLAN bit ใน the receive frame status ถูกเซ็ต. The legal length of the frame ถูกเพิ่มจาก 1518 bytes เป็น 1522 bytes.

(https://i.imgur.com/NZyxYr9.png)

Bits 31:17 Reserved, must be kept at reset value.

Bit 16 VLANTC: 12-bit VLAN tag comparison
เมื่อบิตนี้ถูกเซ็ต, a 12-bit VLAN identifier, แทนที่จะเป็น the complete 16-bit VLAN tag, ถูกใช้สำหรับ comparison and filtering. Bits[11:0] of the VLAN tag ถูกเปรียบเทียบกับ the corresponding field ใน the received VLAN-tagged frame.
เมื่อบิตนี้ถูกรีเซ็ต, ไบต์ที่สิบห้าและสิบหกของ all 16 bits of the received VLAN frame ถูกใช้สำหรับ comparison.

Bits 15:0 VLANTI: VLAN tag identifier (for receive frames)
นี้บรรจุ the 802.1Q VLAN tag เพื่อระบุ VLAN frames, และถูกเปรียบเทียบกับไบต์ที่สิบห้าและที่สิบหกของ the frames กำลังถูกรับสำหรับ VLAN frames. Bits[15:13] คือ the user priority, Bit[12] คือ the canonical format indicator (CFI) และ bits[11:0] คือ VLAN identifier (VID) field ของ the VLAN tag. เมื่อ the VLANTC bit ถูกเซ็ต, เฉพาะ the VID (bits[11:0]) ถูกใช้สำหรับ comparison.
ถ้า VLANTI (VLANTI[11:0] ถ้า VLANTC ถูกเซ็ต) เป็นศูนย์ทั้งหมด, the MAC จะไม่ตรวจสอบ the fifteenth and sixteenth bytes สำหรับ VLAN tag comparison, และประกาศ frames ทั้งหมดที่มี a Type field value of 0x8100 ว่าเป็น VLAN frames.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 23, 2021, 11:00:57 AM
Ethernet MAC remote wakeup frame filter register (ETH_MACRWUFFR)

Address offset: 0x0028
Reset value: 0x0000 0000

นี้คือ the address ที่ the remote wakeup frame filter registers ถูกเขียน/อ่านโดย the application. The Wakeup frame filter register จริงๆแล้วเป็นตัวชี้ไปยังแปด (ไม่โปร่งใส) wakeup frame filter registers ดังกล่าว. Eight sequential write operations ไปยัง address นี้ด้วย the offset (0x0028) จะเขียน all wakeup frame filter registers. Eight sequential read operations จาก address นี้ด้วย the offset (0x0028) จะอ่าน all wakeup frame filter registers. register นี้บรรจุ the higher 16 bits ของ the 7th MAC address. อ้างอิงถึง Remote wakeup frame filter register section สำหรับข้อมูลเพิ่มเติม.

(https://i.imgur.com/6MfU6Jg.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on March 23, 2021, 04:22:14 PM
Ethernet MAC PMT control and status register (ETH_MACPMTCSR)

Address offset: 0x002C
Reset value: 0x0000 0000

The ETH_MACPMTCSR โปรแกรม the request wakeup events และมอนิเตอร์ the wakeup events.

(https://i.imgur.com/hduliK5.png)

Bit 31 WFFRPR: Wakeup frame filter register pointer reset
เมื่อเซ็ต, มันรีเซ็ต the Remote wakeup frame filter register ชี้ไปยัง 0b000. มันถูกเคลียร์โดยอัตโนมัติหลังจาก 1 clock cycle.

Bits 30:10 Reserved, must be kept at reset value.

Bit 9 GU: Global unicast
เมื่อเซ็ต, มันเปิดการใช้งาน any unicast packet ที่กรองโดย the MAC (DAF) address recognition ให้เป็น a wakeup frame.

Bits 8:7 Reserved, must be kept at reset value.

Bit 6 WFR: Wakeup frame received
เมื่อเซ็ต, บิตนี้แสดงให้เห็น the power management event ถูกสร้างขึ้นเนื่องจากการรับของ a wakeup frame. บิตนี้ถูกเคลียร์โดยการอ่านลงใน register นี้.

Bit 5 MPR: Magic packet received
เมื่อเซ็ต, บิตนี้แสดงให้เห็น the power management event ถูกสร้างขึ้นเนื่องจากการรับของ a Magic Packet. บิตนี้ถูกเคลียร์โดยการอ่านลงใน register นี้.

Bits 4:3 Reserved, must be kept at reset value.

Bit 2 WFE: Wakeup frame enable
เมื่อเซ็ต, บิตนี้เปิดการใช้งานการสร้างของ a power management event เนื่องจาก wakeup frame reception.

Bit 1 MPE: Magic Packet enable
เมื่อเซ็ต, บิตนี้เปิดการใช้งานการสร้างของ a power management event เนื่องจาก Magic Packet reception.

Bit 0 PD: Power down
เมื่อบิตนี้ถูกเซ็ต, all received frames จะถูกดร็อป. บิตนี้ถูกเคลียร์โดยอัตโนมัติเมื่อ a magic packet หรือ wakeup frame ถูกรับ, และ Power-down mode ถูกปิดการใช้งาน. Frames ที่รับหลังจากบิตนี้ถูกเคลียร์จะถูกส่งต่อไปยัง the application. บิตนี้ต้องถูกเซ็ตเฉพาะเมื่ออย่างใดอย่างหนึ่ง the Magic Packet Enable หรือ Wakeup Frame Enable bit ถูกเซ็ต high.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 24, 2021, 07:13:15 AM
Ethernet MAC interrupt status register (ETH_MACSR)

Address offset: 0x0038
Reset value: 0x0000 0000

The ETH_MACSR register contents ระบุ the events ใน the MAC ที่สามารถสร้าง an interrupt.

(https://i.imgur.com/elUzTtr.png)

Bits 15:10 Reserved, must be kept at reset value.

Bit 9 TSTS: Time stamp trigger status
บิตนี้ถูกเซ็ต high เมื่อ the system time value เท่ากับหรือเกินค่าที่ระบุใน the Target time high and low registers. บิตนี้ถูกเคลียร์โดยการอ่าน the ETH_PTPTSSR register.

Bits 8:7 Reserved, must be kept at reset value.

Bit 6 MMCTS: MMC transmit status
บิตนี้ถูกเซ็ต high เมื่อใดก็ตามที่ an interrupt ถูกสร้างขึ้นใน the ETH_MMCTIR Register. บิตนี้ถูกเคลียร์เมื่อทุก the bits ใน interrupt register (ETH_MMCTIR) นี้ถูกเคลียร์.

Bit 5 MMCRS: MMC receive status
บิตนี้ถูกเซ็ต high เมื่อใดก็ตามที่ an interrupt ถูกสร้างขึ้นใน the ETH_MMCRIR Register. บิตนี้ถูกเคลียร์เมื่อทุก the bits ใน interrupt register (ETH_MMCRIR) นี้ถูกเคลียร์.

Bit 4 MMCS: MMC status
บิตนี้ถูกเซ็ต high เมื่อใดก็ตามที่อันหนึ่งอันใด bits 6:5 ถูกเซ็ต high. มันถูกเคลียร์เฉพาะเมื่อทั้งสองบิตเป็น low.

Bit 3 PMTS: PMT status
บิตนี้ถูกเซ็ตเมื่อใดก็ตามที่ a Magic packet หรือ Wake-on-LAN frame ถูกรับใน Power-down mode (ดู bits 5 and 6 in the ETH_MACPMTCSR register Ethernet MAC PMT control and status register (ETH_MACPMTCSR)). บิตนี้ถูกเคลียร์เมื่อทั้งสอง bits[6:5], ของ last register นี้, ถูกเคลียร์เนื่องจาก a read operation ไปยัง the ETH_MACPMTCSR register.

Bits 2:0 Reserved, must be kept at reset value.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 24, 2021, 08:44:36 AM
Ethernet MAC interrupt mask register (ETH_MACIMR)

Address offset: 0x003C
Reset value: 0x0000 0000

The ETH_MACIMR register bits ทำมันเป็นไปได้ที่จะบัง the interrupt signal เนื่องจาก the corresponding event ใน the ETH_MACSR register.

(https://i.imgur.com/Mdp3nL4.png)

Bits 15:10 Reserved, must be kept at reset value.

Bit 9 TSTIM: Time stamp trigger interrupt mask
เมื่อเซ็ต, บิตนี้ปิดการใช้งาน the time stamp interrupt generation.

Bits 8:4 Reserved, must be kept at reset value.

Bit 3 PMTIM: PMT interrupt mask
เมื่อเซ็ต, บิตนี้ปิดการใช้งานการถือสิทธิ์ของ the interrupt signal เนื่องจากการเซ็ตของ the PMT Status bit ใน ETH_MACSR.

Bits 2:0 Reserved, must be kept at reset value.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 24, 2021, 09:35:41 AM
Ethernet MAC address 0 high register (ETH_MACA0HR)

Address offset: 0x0040
Reset value: 0x8000 FFFF

The MAC address 0 high register ถือ(เก็บ) the upper 16 bits of the 6-byte first MAC address of the station. โปรดสังเกตว่า the first DA byte ที่ถูกรับบน the MII interface ตรงกันกับ the LS Byte (bits [7:0]) of the MAC address low register. ตัวอย่างเช่น, ถ้า 0x1122 3344 5566 ถูกรับ (0x11 คือ the first byte) บน the MII เป็น the destination address, จากนั้น the MAC address 0 register [47:0] ถูกเปรียบเทียบกับ 0x6655 4433 2211.

(https://i.imgur.com/dkLVtQl.png)

Bit 31 MO: เป็น 1 เสมอ.

Bits 30:16 Reserved, must be kept at reset value.

Bits 15:0 MACA0H: MAC address0 high [47:32]
field นี้บรรจุ the upper 16 bits (47:32) of the 6-byte MAC address0. นี้ถูกใช้โดย the MAC สำหรับการกรอง received frames และสำหรับการใส่ the MAC address ใน the transmit flow control (Pause) frames.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 24, 2021, 09:49:41 AM
Ethernet MAC address 0 low register (ETH_MACA0LR)

Address offset: 0x0044
Reset value: 0xFFFF FFFF

The MAC address 0 low register เก็บ the lower 32 bits of the 6-byte first MAC address of the station.

(https://i.imgur.com/0wwykOg.png)

Bits 31:0 MACA0L: MAC address0 low [31:0]
field นี้บรรจุ the lower 32 bits of the 6-byte MAC address0. นี้ถูกใช้โดย the MAC สำหรับการกรอง received frames และสำหรับการใส่ the MAC address ใน the transmit flow control (Pause) frames.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 24, 2021, 10:21:00 AM
Ethernet MAC address 1 high register (ETH_MACA1HR)

Address offset: 0x0048
Reset value: 0x0000 FFFF

The MAC address 1 high register เก็บ the upper 16 bits of the 6-byte second MAC address of the station.

(https://i.imgur.com/JmtBl45.png)

Bit 31 AE: Address enable
เมื่อบิตนี้ถูกเซ็ต, the address filters ใช้ the MAC address1 สำหรับ perfect filtering. เมื่อบิตนี้ถูกเคลียร์, the address filters จะไม่สนใจ the address สำหรับการกรอง.

Bit 30 SA: Source address
เมื่อบิตนี้ถูกเซ็ต, the MAC address1[47:0] ถูกใช้สำหรับการเปรียบเทียบกับ the SA fields of the received frame.
เมื่อบิตนี้ถูกเคลียร์, the MAC address1[47:0] ถูกใช้สำหรับการเปรียบเทียบกับ the DA fields of the received frame.

Bits 29:24 MBC: Mask byte control
บิตเหล่านี้คือ mask control bits สำหรับการเปรียบเทียบของแต่ละ the MAC address1 bytes. เมื่อบิตเหล่านี้ถูกเซ็ต high, the MAC core จะไม่เปรียบเทียบ byte ที่ตรงกันของ received DA/SA กับสิ่งที่อยู่ภายในของ the MAC address1 registers. แต่ละบิตควบคุมการบังของ the bytes ดังต่อไปนี้:
     – Bit 29: ETH_MACA1HR [15:8]
     – Bit 28: ETH_MACA1HR [7:0]
     – Bit 27: ETH_MACA1LR [31:24]
     ...
     – Bit 24: ETH_MACA1LR [7:0]

Bits 23:16 Reserved, must be kept at reset value.

Bits 15:0 MACA1H: MAC address1 high [47:32]
field นี้บรรจุ the upper 16 bits (47:32) of the 6-byte second MAC address.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 24, 2021, 10:38:09 AM
Ethernet MAC address1 low register (ETH_MACA1LR)

Address offset: 0x004C
Reset value: 0xFFFF FFFF

The MAC address 1 low register เก็บ the lower 32 bits of the 6-byte second MAC address of the station.

(https://i.imgur.com/nog8ewt.png)

Bits 31:0 MACA1L: MAC address1 low [31:0]
field นี้บรรจุ the lower 32 bits of the 6-byte MAC address1. สิ่งที่อยู่ภายในของ field นี้ไม่ได้กำหนดจนกระทั่งถูกโหลดโดย the application หลังจาก the initialization process.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 24, 2021, 02:02:03 PM
Ethernet MAC address 2 high register (ETH_MACA2HR)

Address offset: 0x0050
Reset value: 0x0000 FFFF

The MAC address 2 high register เก็บ the upper 16 bits of the 6-byte second MAC address of the station.

(https://i.imgur.com/KdQcuos.png)

Bit 31 AE: Address enable
เมื่อบิตนี้ถูกเซ็ต, the address filters ใช้ the MAC address2 สำหรับ perfect filtering. เมื่อบิตนี้ถูกเคลียร์, the address filters จะไม่สนใจ the address สำหรับการกรอง.

Bit 30 SA: Source address
เมื่อบิตนี้ถูกเซ็ต, the MAC address2[47:0] ถูกใช้สำหรับการเปรียบเทียบกับ the SA fields of the received frame.
เมื่อบิตนี้ถูกเคลียร์, the MAC address2[47:0] ถูกใช้สำหรับการเปรียบเทียบกับ the DA fields of the received frame.

Bits 29:24 MBC: Mask byte control
บิตเหล่านี้คือ mask control bits สำหรับการเปรียบเทียบของแต่ละ the MAC address2 bytes. เมื่อบิตเหล่านี้ถูกเซ็ต high, the MAC core จะไม่เปรียบเทียบ byte ที่ตรงกันของ received DA/SA กับสิ่งที่อยู่ภายในของ the MAC address2 registers. แต่ละบิตควบคุมการบังของ the bytes ดังต่อไปนี้:
– Bit 29: ETH_MACA2HR [15:8]
– Bit 28: ETH_MACA2HR [7:0]
– Bit 27: ETH_MACA2LR [31:24]
...
– Bit 24: ETH_MACA2LR [7:0]

Bits 23:16 Reserved, must be kept at reset value.

Bits 15:0 MACA2H: MAC address2 high [47:32]
field นี้บรรจุ the upper 16 bits (47:32) of the 6-byte MAC address2.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 24, 2021, 02:04:19 PM
Ethernet MAC address 2 low register (ETH_MACA2LR)

Address offset: 0x0054
Reset value: 0xFFFF FFFF

The MAC address 2 low register เก็บ the lower 32 bits of the 6-byte second MAC address of the station.

(https://i.imgur.com/WLCdRKE.png)

Bits 31:0 MACA2L: MAC address2 low [31:0]
field นี้บรรจุ the lower 32 bits of the 6-byte second MAC address2. สิ่งที่อยู่ภายในของ field นี้ไม่ได้กำหนดจนกระทั่งถูกโหลดโดย the application หลังจาก the initialization process.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 24, 2021, 02:07:08 PM
Ethernet MAC address 3 high register (ETH_MACA3HR)

Address offset: 0x0058
Reset value: 0x0000 FFFF

The MAC address 3 high register เก็บ the upper 16 bits of the 6-byte second MAC address of the station.

(https://i.imgur.com/VSBLNj2.png)

Bit 31 AE: Address enable
เมื่อบิตนี้ถูกเซ็ต, the address filters ใช้ the MAC address3 สำหรับ perfect filtering. เมื่อบิตนี้ถูกเคลียร์, the address filters จะไม่สนใจ the address สำหรับการกรอง.

Bit 30 SA: Source address
เมื่อบิตนี้ถูกเซ็ต, the MAC address3[47:0] ถูกใช้สำหรับการเปรียบเทียบกับ the SA fields of the received frame.
เมื่อบิตนี้ถูกเคลียร์, the MAC address3[47:0] ถูกใช้สำหรับการเปรียบเทียบกับ the DA fields of the received frame.

Bits 29:24 MBC: Mask byte control
บิตเหล่านี้คือ mask control bits สำหรับการเปรียบเทียบของแต่ละ the MAC address3 bytes. เมื่อบิตเหล่านี้ถูกเซ็ต high, the MAC core จะไม่เปรียบเทียบ byte ที่ตรงกันของ received DA/SA กับสิ่งที่อยู่ภายในของ the MAC address3 registers. แต่ละบิตควบคุมการบังของ the bytes ดังต่อไปนี้:
– Bit 29: ETH_MACA3HR [15:8]
– Bit 28: ETH_MACA3HR [7:0]
– Bit 27: ETH_MACA3LR [31:24]
...
– Bit 24: ETH_MACA3LR [7:0]

Bits 23:16 Reserved, must be kept at reset value.

Bits 15:0 MACA3H: MAC address3 high [47:32]
field นี้บรรจุ the upper 16 bits (47:32) of the 6-byte MAC address3.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 24, 2021, 02:09:16 PM
Ethernet MAC address 3 low register (ETH_MACA3LR)

Address offset: 0x005C
Reset value: 0xFFFF FFFF

The MAC address 3 low register เก็บ the lower 32 bits of the 6-byte second MAC address of the station.

(https://i.imgur.com/YPV3Aso.png)

Bits 31:0 MACA3L: MAC address3 low [31:0]
field นี้บรรจุ the lower 32 bits of the 6-byte second MAC address3. สิ่งที่อยู่ภายในของ field นี้ไม่ได้กำหนดจนกระทั่งถูกโหลดโดย the application หลังจาก the initialization process.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 25, 2021, 07:09:48 AM
29.8.2 MMC register description

Ethernet MMC control register (ETH_MMCCR)

Address offset: 0x0100
Reset value: 0x0000 0000

The Ethernet MMC Control register สร้าง the operating mode of the management counters.

(https://i.imgur.com/zurmslJ.png)

Bits 31:4 Reserved, must be kept at reset value.

Bit 3 MCF: MMC counter freeze
เมือเซ็ต, บิตนี้จะตรึง the MMC counters ทั้งหมดเป็นค่าปัจจุบันของมัน. (ไม่มี the MMC counters ถูกอัปเดตเนื่องจาก any transmitted or received frame จนกระทั่งบิตนี้ถูกเคลียร์เป็น 0. ถ้า MMC counter ใดๆถูกอ่านด้วย the Reset บน Read bit เซ็ต, จากนั้น counter นั้นจะถูกเคลียร์ในโหมดนี้อีกด้วย.)

Bit 2 ROR: Reset on read
เมื่อบิตนี้ถูกเซ็ต, the MMC counters ถูกรีเซ็ตเป็นศูนย์หลังจากการอ่าน (การเคลียร์ตัวเองหลังจาก reset). The counters ถูกเคลียร์เมื่อ the least significant byte lane (bits [7:0]) ถูกอ่าน.

Bit 1 CSR: Counter stop rollover
เมื่อบิตนี้ถูกเซ็ต, the counter ไม่วนกลับเป็นศูนย์หลังจากมันถึงค่าสูงสุด.

Bit 0 CR: Counter reset
เมื่อมันถูกเซ็ต, counters ทั้งหมดถูกรีเซ็ต. บิตนี้ถูกเคลียร์โดยอัตโนมัติหลังจาก 1 clock cycle.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 25, 2021, 07:32:28 AM
Ethernet MMC receive interrupt register (ETH_MMCRIR)

Address offset: 0x0104
Reset value: 0x0000 0000

The Ethernet MMC receive interrupt register จะรักษา the interrupts ที่สร้างขึ้นเมื่อ receive statistic counters ถึงครึ่งหนึ่งของค่าสูงสุดของมัน. (MSB of the counter ถูกเซ็ต.) มันคือ a 32-bit wide register. An interrupt bit ถูกเคลียร์เมื่อ the respective MMC counter ที่ทำให้เกิด the interrupt ถูกอ่าน. The least significant byte lane (bits [7:0]) of the respective counter ต้องถูกอ่านเพื่อเคลียร์ the interrupt bit.

(https://i.imgur.com/aNF96iz.png)

Bits 31:18 Reserved, must be kept at reset value.

Bit 17 RGUFS: Received Good Unicast Frames Status
บิตนี้ถูกเซ็ตเมื่อ the received, good unicast frames, counter ถึงครึ่งหนึ่ง the maximum value.

Bits 16:7 Reserved, must be kept at reset value.

Bit 6 RFAES: Received frames alignment error status
บิตนี้ถูกเซ็ตเมื่อ the received frames, ที่มี alignment error, counter ถึงครึ่งหนึ่ง the maximum value.

Bit 5 RFCES: Received frames CRC error status
บิตนี้ถูกเซ็ตเมื่อ the received frames, ที่มี CRC error, counter ถึงครึ่งหนึ่ง the maximum value.

Bits 4:0 Reserved, must be kept at reset value.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 25, 2021, 09:21:12 AM
Ethernet MMC transmit interrupt register (ETH_MMCTIR)

Address offset: 0x0108
Reset value: 0x0000 0000

The Ethernet MMC transmit interrupt register จะรักษา the interrupts ที่สร้างขึ้นเมื่อ transmit statistic counters ถึงครึ่งหนึ่งของค่าสูงสุดของมัน. (MSB of the counter ถูกเซ็ต.) มันคือ a 32-bit wide register. An interrupt bit ถูกเคลียร์เมื่อ the respective MMC counter ที่ทำให้เกิด the interrupt ถูกอ่าน. The least significant byte lane (bits [7:0]) of the respective counter ต้องถูกอ่านเพื่อเคลียร์ the interrupt bit.

(https://i.imgur.com/2DZDZGk.png)

Bits 31:22 Reserved, must be kept at reset value.

Bit 21 TGFS: Transmitted good frames status
บิตนี้ถูกเซ็ตเมื่อ the transmitted, good frames, counter ถึงครึ่งหนึ่ง the maximum value.

Bits 20:16 Reserved, must be kept at reset value.

Bit 15 TGFMSCS: Transmitted good frames more single collision status
บิตนี้ถูกเซ็ตเมื่อ the transmitted, good frames หลังจากมากกว่า a single collision, counter ถึงครึ่งหนึ่ง the maximum value.

Bit 14 TGFSCS: Transmitted good frames single collision status
บิตนี้ถูกเซ็ตเมื่อ the transmitted, good frames หลังจาก a single collision, counter ถึงครึ่งหนึ่ง the maximum value.

Bits 13:0 Reserved, must be kept at reset value.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 25, 2021, 09:45:10 AM
Ethernet MMC receive interrupt mask register (ETH_MMCRIMR)

Address offset: 0x010C
Reset value: 0x0000 0000

The Ethernet MMC receive interrupt mask register จะรักษาการบังของ interrupts ที่สร้างขึ้นเมื่อ the receive statistic counters ถึงครึ่งหนึ่งของค่าสูงสุดของมัน. (MSB of the counter ถูกเซ็ต.) มันคือ a 32-bit wide register.

(https://i.imgur.com/wSjDkZ5.png)

Bits 31:18 Reserved, must be kept at reset value.

Bit 17 RGUFM: Received good unicast frames mask
การเซ็ตบิตนี้จะบังไม่ให้เกิด the interrupt เมื่อ the received, good unicast frames, counter ถึงครึ่งหนึ่ง the maximum value.

Bits 16:7 Reserved, must be kept at reset value.

Bit 6 RFAEM: Received frames alignment error mask
การเซ็ตบิตนี้จะบังไม่ให้เกิด the interrupt เมื่อ the received frames, ที่มี alignment error, counter ถึงครึ่งหนึ่ง the maximum value.

Bit 5 RFCEM: Received frame CRC error mask
การเซ็ตบิตนี้จะบังไม่ให้เกิด the interrupt เมื่อ the received frames, ที่มี CRC error, counter ถึงครึ่งหนึ่ง the maximum value.

Bits 4:0 Reserved, must be kept at reset value.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 25, 2021, 10:05:58 AM
Ethernet MMC transmit interrupt mask register (ETH_MMCTIMR)

Address offset: 0x0110
Reset value: 0x0000 0000

The Ethernet MMC transmit interrupt mask register จะรักษาการบังสำหรับ interrupts ที่สร้างขึ้นเมื่อ the transmit statistic counters ถึงครึ่งหนึ่งของค่าสูงสุดของมัน. (MSB of the counter ถูกเซ็ต.) มันคือ a 32-bit wide register.

(https://i.imgur.com/JmOJah3.png)

Bits 31:22 Reserved, must be kept at reset value.

Bit 21 TGFM: Transmitted good frames mask
การเซ็ตบิตนี้จะบังไม่ให้เกิด the interrupt เมื่อ the transmitted, good frames, counter ถึงครึ่งหนึ่ง the maximum value.

Bits 20:16 Reserved, must be kept at reset value.

Bit 15 TGFMSCM: Transmitted good frames more single collision mask
การเซ็ตบิตนี้จะบังไม่ให้เกิด the interrupt เมื่อ the transmitted good frames หลังจากมากกว่า a single collision, counter ถึงครึ่งหนึ่ง the maximum value.

Bit 14 TGFSCM: Transmitted good frames single collision mask
การเซ็ตบิตนี้จะบังไม่ให้เกิด the interrupt เมื่อ the transmitted good frames หลังจาก a single collision, counter ถึงครึ่งหนึ่ง the maximum value.

Bits 13:0 Reserved, must be kept at reset value.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 25, 2021, 10:31:57 AM
Ethernet MMC transmitted good frames after a single collision counter register (ETH_MMCTGFSCCR)

Address offset: 0x014C
Reset value: 0x0000 0000

register นี้บรรจุจำนวนของ successfully transmitted frames หลังจาก a single collision ใน Half-duplex mode.

(https://i.imgur.com/jIH9puc.png)

Bits 31:0 TGFSCC: Transmitted good frames single collision counter
Transmitted good frames หลังจาก a single collision counter.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 25, 2021, 10:37:13 AM
Ethernet MMC transmitted good frames after more than a single collision counter register (ETH_MMCTGFMSCCR)

Address offset: 0x0150
Reset value: 0x0000 0000

register นี้บรรจุจำนวนของ successfully transmitted frames หลังจากมากกว่า a single collision ใน Half-duplex mode.

(https://i.imgur.com/67FcywI.png)

Bits 31:0 TGFMSCC: Transmitted good frames more single collision counter
Transmitted good frames หลังจากมากกว่า a single collision counter
Title: Re: STM32F1 ETHERNET
Post by: tha on March 25, 2021, 01:29:47 PM
Ethernet MMC transmitted good frames counter register (ETH_MMCTGFCR)

Address offset: 0x0168
Reset value: 0x0000 0000

register นี้บรรจุจำนวนของ good frames ที่ถูกส่ง

(https://i.imgur.com/yojJSTh.png)

Bits 31:0 TGFC: Transmitted good frames counter
Title: Re: STM32F1 ETHERNET
Post by: tha on March 25, 2021, 01:33:44 PM
Ethernet MMC received frames with CRC error counter register (ETH_MMCRFCECR)

Address offset: 0x0194
Reset value: 0x0000 0000

register นี้บรรจุจำนวนของ frames ที่ถูกรับที่มี CRC error.

(https://i.imgur.com/ubzDNRf.png)

Bits 31:0 RFCEC: Received frames CRC error counter
Received frames ที่มี CRC error counter
Title: Re: STM32F1 ETHERNET
Post by: tha on March 25, 2021, 01:37:13 PM
Ethernet MMC received frames with alignment error counter register (ETH_MMCRFAECR)

Address offset: 0x0198
Reset value: 0x0000 0000

register นี้บรรจุจำนวนของ frames ที่ถูกรับที่มี alignment (dribble) error.

(https://i.imgur.com/nVLo9bw.png)

Bits 31:0 RFAEC: Received frames alignment error counter
Received frames ที่มี alignment error counter
Title: Re: STM32F1 ETHERNET
Post by: tha on March 25, 2021, 01:40:51 PM
MMC received good unicast frames counter register (ETH_MMCRGUFCR)

Address offset: 0x01C4
Reset value: 0x0000 0000

register นี้บรรจุจำนวนของ good unicast frames ที่ถูกรับ.

(https://i.imgur.com/JJwwOtt.png)

Bits 31:0 RGUFC: Received good unicast frames counter
Title: Re: STM32F1 ETHERNET
Post by: tha on March 26, 2021, 07:47:30 AM
29.8.3 IEEE 1588 time stamp registers

ส่วนนี้อธิบาย the registers ที่ต้องการเพื่อรองรับ precision network clock synchronization functions ภายใต้ the IEEE 1588 standard.

Ethernet PTP time stamp control register (ETH_PTPTSCR)

Address offset: 0x0700
Reset value: 0x0000 0000

register นี้ควบคุม the time stamp generation และ update logic.

(https://i.imgur.com/1pVUVMs.png)

Bits 31:6 Reserved, must be kept at reset value.

Bit 5 TSARU: Time stamp addend register update
เมื่อบิตนี้ถูกเซ็ต, สิ่งที่อยู่ภายในของ the Time stamp addend register ถูกอัปเดตเป็น the PTP block เพื่อการแก้ไขที่ดี. บิตนี้ถูกเคลียร์เมื่อการอัปเดตเสร็จสมบูรณ์. register bit นี้ต้องถูกอ่านเป็นศูนย์ก่อนที่คุณจะสามารถเซ็ตมัน.

Bit 4 TSITE: Time stamp interrupt trigger enable
เมื่อบิตนี้ถูกเซ็ต, a time stamp interrupt ถูกสร้างขึ้นเมื่อ the system time มาเป็นมากกว่าค่าที่ถูกเขียนใน Target Time register. เมื่อ the Time Stamp Trigger interrupt ถูกสร้างขึ้น, บิตนี้จะถูกเคลียร์.

Bit 3 TSSTU: Time stamp system time update
เมื่อบิตนี้ถูกเซ็ต, the system time ถูกอัปเดต (บวกไปยังหรือลบออกจาก) ด้วยค่าที่ระบุใน the Time stamp high update และ Time stamp low update registers. ทั้งสอง the TSSTU และ TSSTI bits ต้องถูกอ่านเป็นศูนย์ก่อนที่คุณสามารถเซ็ตบิตนี้. เมื่อการอัปเดตเสร็จสมบูรณ์ใน hardware, บิตนี้จะถูกเคลียร์.

Bit 2 TSSTI: Time stamp system time initialize
เมื่อบิตนี้ถูกเซ็ต, the system time ถูกเริ่มต้น (เขียนทับ) ด้วยค่าที่ระบุใน the Time stamp high update and Time stamp low update registers. บิตนี้ต้องถูกอ่านเป็นศูนย์ก่อนที่คุณสามารถเซ็ตมัน. เมื่อการเริ่มต้นเสร็จสมบูรณ์, บิตนี้จะถูกเคลียร์.

Bit 1 TSFCU: Time stamp fine or coarse update
เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่า the system time stamp จะต้องถูกอัปเดตโดยใช้ the Fine Update method. เมื่อเคลียร์, มันแสดงให้เห็น the system time stamp จะต้องถูกอัปเดตโดยใช้ the Coarse method.

Bit 0 TSE: Time stamp enable
เมื่อบิตนี้ถูกเซ็ต, time stamping ถูกเปิดการใช้งานสำหรับ transmit and receive frames. เมื่อบิตนี้ถูกเคลียร์, the time stamp function ถูกแขวนไว้และ time stamps จะไม่ถูกเพิ่มสำหรับ transmit and receive frames. เนื่องจาก the maintained system time ถูกแขวน, คุณต้องเริ่มต้น the time stamp feature (system time) เสมอหลังจากการเซ็ตบิตนี้เป็น high.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 26, 2021, 09:26:54 AM
Ethernet PTP subsecond increment register (ETH_PTPSSIR)

Address offset: 0x0704
Reset value: 0x0000 0000

register นี้บรรจุ the 8-bit value โดยที่ the subsecond register ถูกเพิ่มขึ้น. ใน Coarse update mode (TSFCU bit in ETH_PTPTSCR), ค่าใน register นี้ถูกเพิ่มไปยัง the system time ทุกๆ clock cycle of HCLK. ใน Fine update mode, ค่าใน register นี้ถูกเพิ่มไปยัง the system time เมื่อไรก็ตามที่ the accumulator เกิด an overflow

(https://i.imgur.com/L5fxlPI.png)

Bits 31:8 Reserved, must be kept at reset value.

Bits 7:0 STSSI: System time subsecond increment
ค่าที่ถูกโปรแกรมใน register นี้ถูกเพิ่มไปยังสิ่งที่อยู่ภายในของ the subsecond value ของ the system time ในทุกๆอัปเดตe.
ตัวอย่างเช่น, เพื่อให้ได้ความแม่นยำ 20 ns, ค่าคือ : 20 / 0.467 = ~ 43 (or 0x2A).
Title: Re: STM32F1 ETHERNET
Post by: tha on March 26, 2021, 02:33:10 PM
Ethernet PTP time stamp high register (ETH_PTPTSHR)

Address offset: 0x0708
Reset value: 0x0000 0000

register นี้บรรจุ the most significant (higher) 32 time bits. read-only register นี้บรรจุ the seconds system time value. The Time stamp high register, พร้อมกับ Time stamp low register, แสดงให้เห็นค่าปัจจุบันของ the system time ที่ดูแลโดย the MAC. แม้ว่ามันถูกอัปเดตอย่างต่อเนื่อง.

(https://i.imgur.com/4jJBsV4.png)

Bits 31:0 STS: System time second
ค่าใน field นี้แสดงให้เห็นค่าปัจจุบันเป็น seconds ของ the System Time ที่ดูแลโดย the core.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 26, 2021, 02:49:19 PM
Ethernet PTP time stamp low register (ETH_PTPTSLR)

Address offset: 0x070C
Reset value: 0x0000 0000

register นี้บรรจุ the least significant (lower) 32 time bits. read-only register นี้บรรจุ the subsecond system time value.

(https://i.imgur.com/hgTgRhQ.png)

Bit 31 STPNS: System time positive or negative sign
บิตนี้แสดงให้เห็น a positive หรือ negative time value. เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่าการแสดงเวลาเป็น negative. เมื่อเคลียร์, บิตนี้แสดงให้เห็นว่าการแสดงเวลาเป็น positive. เนื่องจาก the system time ควรเป็น positive เสมอ, บิตนี้ปกติเป็นศูนย์.

Bits 30:0 STSS: System time subseconds
ค่าใน field นี้มี the subsecond time representation, ที่มี 0.46 ns accuracy.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 27, 2021, 07:04:27 AM
Ethernet PTP time stamp high update register (ETH_PTPTSHUR)

Address offset: 0x0710
Reset value: 0x0000 0000

register นี้บรรจุ the most significant (higher) 32 bits ของ the time ที่ถูกเขียนไปยัง, เพิ่มไปยัง, หรือลบออกจาก the System Time value. The Time stamp high update register, พร้อมกับ the Time stamp update low register, เริ่มต้นหรืออัปเดต the system time ที่ค้ำจุนไว้โดย the MAC. คุณต้องเขียนทั้งสอง registers นี้ก่อนการเซ็ต the TSSTI or TSSTU bits ใน the Time stamp control register.

(https://i.imgur.com/AbhzRyf.png)

Bits 31:0 TSUS: Time stamp update second
ค่าใน field นี้แสดงให้เห็น the time, เป็น seconds, ที่จะถูกเริ่มต้นหรือเพิ่มไปยัง the system time.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 27, 2021, 07:08:14 AM
Ethernet PTP time stamp low update register (ETH_PTPTSLUR)

Address offset: 0x0714
Reset value: 0x0000 0000

register นี้บรรจุ the least significant (lower) 32 bits ของ the time ที่ถูกเขียนไปยัง, เพิ่มไปยัง, หรือลบออกจาก the System Time value.

(https://i.imgur.com/lVG72WN.png)

Bit 31 TSUPNS: Time stamp update positive or negative sign
บิตนี้แสดงให้เห็น a positive หรือ negative time value. เมื่อเซ็ต, บิตนี้แสดงให้เห็นว่าการแสดงเวลาเป็น negative. เมื่อเคลียร์, บิตนี้แสดงให้เห็นว่าการแสดงเวลาเป็น positive. เมื่อ TSSTI ถูกเซ็ต (system time initialization) บิตนี้ควรเป็นศูนย์. ถ้าบิตนี้ถูกเซ็ตเมื่อ TSSTU ถูกเซ็ต, ค่าใน the Time stamp update registers จะถูกลบออกจาก the system time. มิฉะนั้นมันจะถูกเพิ่มไปยัง the system time.

Bits 30:0 TSUSS: Time stamp update subseconds
ค่าใน field นี้แสดงให้เห็น the subsecond time ที่จะถูกเริ่มต้นหรือเพิ่มไปยัง the system time. ค่านี้มีความแม่นยำ 0.46 ns (กล่าวอีกนัยหนึ่ง, ค่าของ 0x0000_0001 คือ 0.46 ns).
Title: Re: STM32F1 ETHERNET
Post by: tha on March 27, 2021, 08:33:16 AM
Ethernet PTP time stamp addend register (ETH_PTPTSAR)

Address offset: 0x0718
Reset value: 0x0000 0000

register นี้ถูกใช้โดย the software เพื่อปรับใหม่ the clock frequency เป็นเชิงเส้นให้ตรงกับ the master clock frequency. register value นี้ถูกใช้เฉพาะเมื่อ the system time ถูกกำหนดค่าสำหรับ Fine update mode (TSFCU bit in ETH_PTPTSCR). This register content ถูกเพิ่มไปยัง a 32-bit accumulator ในทุกๆ clock cycle และ the system time ถูกอัปเดตเมื่อไรก็ตามที่ the accumulator overflows.

(https://i.imgur.com/p23uXtI.png)

Bits 31:0 TSA: Time stamp addend
register นี้แสดงให้เห็น the 32-bit time value ที่จะถูกเพิ่มไปยัง the Accumulator register เพื่อให้สำเร็จ time synchronization.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 27, 2021, 09:12:57 AM
Ethernet PTP target time high register (ETH_PTPTTHR)

Address offset: 0x071C
Reset value: 0x0000 0000

register นี้บรรจุ the higher 32 bits of time ที่จะถูกเปรียบเทียบกับ the system time สำหรับ interrupt event generation. The Target time high register, พร้อมกับ Target time low register, ถูกใช้เพื่อจัดกำหนดเวลา an interrupt event (TSARU bit ใน ETH_PTPTSCR) เมื่อ the system time เกินค่าที่ถูกโปรแกรมใน registers เหล่านี้.

(https://i.imgur.com/qewOzxD.png)

Bits 31:0 TTSH: Target time stamp high
register นี้จัดเก็บ the time เป็น seconds. เมื่อ the time stamp value ตรงกับหรือเกินทั้งสอง Target time stamp registers, the MAC, ถ้าถูกเปิดการใช้งาน, จะสร้าง an interrupt
Title: Re: STM32F1 ETHERNET
Post by: tha on March 27, 2021, 09:20:26 AM
Ethernet PTP target time low register (ETH_PTPTTLR)

Address offset: 0x0720
Reset value: 0x0000 0000

register นี้บรรจุ the lower 32 bits of time ที่จะถูกเปรียบเทียบกับ the system time สำหรับ interrupt event generation.

(https://i.imgur.com/jxHMRvJ.png)

Bits 31:0 TTSL: Target time stamp low
register นี้จัดเก็บ the time เป็น (signed) nanoseconds. เมื่อค่าของ the time stamp ตรงกับหรือเกินทั้งสอง Target time stamp registers, the MAC, ถ้าถูกเปิดการใช้งาน, จะสร้าง an interrupt.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 27, 2021, 02:40:59 PM
29.8.4 DMA register description

section นี้กำหนด the bits สำหรับแต่ละ DMA register. Non-32 bit accesses ถูกยอมให้ตราบเท่าที่ the address เป็น word-aligned.

Ethernet DMA bus mode register (ETH_DMABMR)

Address offset: 0x1000
Reset value: 0x0002 0101

The bus mode register สร้าง the bus operating modes สำหรับ the DMA.

(https://i.imgur.com/xpXQV7l.png)

Bits 31:26 Reserved, must be kept at reset value

Bit 25 AAB: Address-aligned beats
เมื่อบิตนี้ถูกเซ็ต high และ the FB bit เท่ากับ 1, the AHB interface สร้าง bursts ทั้งหมดจัดแนวให้ตรงกับ the start address LS bits. ถ้า the FB bit เท่ากับ 0, the first burst (การเข้าถึง start address ของ the data buffer) ไม่ถูกจัดแนวให้ตรง, แต่ subsequent bursts จะถูกจัดแนวให้ตรงกับ the address.

Bit 24 FPM: 4xPBL mode
เมื่อเซ็ต high, บิตนี้จะคูณ the PBL value ที่โปรแกรมไว้ (bits [22:17] และ bits [13:8]) สี่ครั้ง. ดังนั้น the DMA ส่งถ่าย data ได้สูงสุด 4, 8, 16, 32, 64 and 128 ครั้งขึ้นอยู่กับ the PBL value.

Bit 23 USP: Use separate PBL
เมื่อเซ็ต high, มันกำหนดค่า the RxDMA เพื่อใช้ค่าที่กำหนดค่าใน bits [22:17] เป็น PBL ในขณะที่ the PBL value ใน bits [13:8] ใช้ได้กับ TxDMA operations เท่านั้น. เมื่อบิตนี้ถูกเคลียร์, the PBL value ใน bits [13:8] ใช้ได้กับทั้งสอง DMA engines.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 27, 2021, 04:36:46 PM
Bits 22:17 RDP: Rx DMA PBL
บิตเหล่านี้แสดงให้เห็นจำนวนสูงสุดของ beats ที่จะถูกส่งถ่ายในหนึ่ง RxDMA transaction. นี้คือค่าสูงสุดที่ถูกใช้ใน a single block read/write operation. The RxDMA พยายาม burst เสมอตามที่ระบุไว้ใน RDP แต่ละเวลาที่มันสตาร์ท a burst transfer บน the host bus. RDP สามารถถูกโปรแกรมด้วยค่าที่ยอมได้ของ 1, 2, 4, 8, 16, and 32. ค่าอื่นใดๆจะส่งผลให้เกิดพฤติกรรมที่ไม่ได้กำหนดไว้.
บิตเหล่านี้ถูกต้องและใช้ได้เฉพาะเมื่อ USP ถูกเซ็ต high.

Bit 16 FB: Fixed burst
บิตนี้ควบคุมว่า the AHB Master interface กระทำ fixed burst transfers หรือไม่. เมื่อเซ็ต, the AHB ใช้เฉพาะ SINGLE, INCR4, INCR8 or INCR16 ในระหว่างการสตาร์ทของ normal burst transfers. เมื่อรีเซ็ต, the AHB ใช้ SINGLE and INCR burst transfer operations.

Bits 15:14 PM: Rx Tx priority ratio
RxDMA requests ได้รับการจัดลำดับความสำคัญเหนือ TxDMA requests ในอัตราส่วนต่อไปนี้:
     00: 1:1
     01: 2:1
     10: 3:1
     11: 4:1
นี้ใช้ได้เฉพาะเมื่อ the DA bit ถูกเคลียร์.

Bits 13:8 PBL: Programmable burst length
บิตเหล่านี้แสดงให้เห็นจำนวนสูงสุดของ beats ที่จะถูกส่งถ่ายในหนึ่ง RxDMA transaction. นี้คือค่าสูงสุดที่ถูกใช้ใน a single block read/write operation. The RxDMA พยายาม burst เสมอตามที่ระบุไว้ใน RDP แต่ละครั้งที่มันสตาร์ท a burst transfer บน the host bus. RDP สามารถถูกโปรแกรมด้วยค่าที่ยอมได้ของ 1, 2, 4, 8, 16, and 32. ค่าอื่นใดๆจะส่งผลให้เกิดพฤติกรรมที่ไม่ได้กำหนดไว้. เมื่อ USP ถูกเซ็ต, PBL value นี้ใช้ได้สำหรับ TxDMA transactions เท่านั้น.
The PBL values มีข้อจำกัดดังต่อไปนี้::
     – จำนวนสูงสุดของ beats (PBL) เป็นไปได้ที่จะถูกจำกัดโดยขนาดของ the Tx FIFO and Rx FIFO.
     – The FIFO มีข้อจำกัดว่า the maximum beat supported คือครึ่งหนึ่งของความลึกของ the FIFO.
     – ถ้า the PBL ใช้ร่วมกันสำหรับทั้ง transmit and receive DMA, the minimum Rx FIFO and Tx FIFO depths ต้องถูก
        พิจารณา.
     – ไม่โปรแกรม out-of-range PBL values, เนื่องจาก the system อาจทำงานไม่ถูกต้อง

Bit 7 Reserved, must be kept at reset value.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 28, 2021, 06:55:08 AM
Bits 6:2 DSL: Descriptor skip length
บิตนี้ระบุจำนวนของ words ที่จะข้ามระหว่างสอง unchained descriptors. The address skipping สตาร์ทจากจุดสิ้นสุดของ current descriptor ไปยังจุดสตาร์ทของ next descriptor. เมื่อ DSL value เท่ากับศูนย์, the descriptor table ถูกยึดอย่างติดกันโดย the DMA, ใน Ring mode.

Bit 1 DA: DMA Arbitration
0: Round-robin ที่มี Rx:Tx priority ที่ให้ไว้ใน bits [15:14]
1: Rx มี priority เหนือ Tx

Bit 0 SR: Software reset
เมื่อบิตนี้ถูกเซ็ต, the MAC DMA controller จะรีเซ็ตทุก MAC Subsystem internal registers และ logic. มันถูกเคลียร์โดยอัตโนมัติหลังจาก the reset operation เสร็จสมบูรณ์ใน the core clock domains ทั้งหมด. อ่านค่า 0 ในบิตนี้ก่อนการโปรแกรมใหม่ register ใดๆของ the core.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 28, 2021, 08:34:17 AM
Ethernet DMA transmit poll demand register (ETH_DMATPDR)

Address offset: 0x1004
Reset value: 0x0000 0000

This register ถูกใช้โดย the application เพื่อสั่งให้ the DMA วนตรวจ the transmit descriptor list. The transmit poll demand register เปิดการใช้งาน the Transmit DMA เพื่อเช็คว่า the current descriptor ถูกเป็นเจ้าของโดย DMA หรือไม่. The Transmit Poll Demand command ถูกให้เพื่อปลุก the TxDMA ถ้ามันอยู่ใน Suspend mode. The TxDMA สามารถไปลงใน Suspend mode เนื่องจาก an underflow error ใน a transmitted frame หรือเนื่องจากความไม่สามารถใช้งานได้ของ descriptors ที่เป็นเจ้าของโดย transmit DMA. คุณสามารถปล่อยออก command นี้เวลาใดก็ได้และ the TxDMA จะรีเซ็ตมันเมื่อมันสตาร์ทการดึงใหม่ the current descriptor จาก host memory.

(https://i.imgur.com/BF1CEtq.png)

Bits 31:0 TPD: Transmit poll demand
เมื่อบิตเหล่านี้ถูกเขียนด้วยค่าใดๆ, the DMA อ่าน the current descriptor ที่ชี้ไปโดย the ETH_DMACHTDR register. ถ้า descriptor นั้นไม่มีให้ใช้งาน (ถูกเป็นเจ้าของโดย Host), transmission กลับคืนสู่ the Suspend state และ ETH_DMASR register bit 2 ถูกถือสิทธิ์. ถ้า the descriptor มีให้ใช้งาน, transmission จะดำเนินการต่อ.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 28, 2021, 09:39:27 AM
EHERNET DMA receive poll demand register (ETH_DMARPDR)

Address offset: 0x1008
Reset value: 0x0000 0000

This register ถูกใช้โดย the application เพื่อสั่งให้ the DMA วนตรวจ the receive descriptor list. The receive poll demand register เปิดการใช้งาน the receive DMA เพื่อเช็คสำหรับ new descriptors. command นี้ถูกให้เพื่อปลุก the RxDMA จาก Suspend state. The RxDMA สามารถไปลงใน Suspend state เฉพาาะเนื่องจากความไม่สามารถใช้งานได้ของ descriptors ที่เป็นเจ้าของโดยมัน.

(https://i.imgur.com/rPaOlZn.png)

Bits 31:0 RPD: Receive poll demand
เมื่อบิตเหล่านี้ถูกเขียนด้วยค่าใดๆ, the DMA อ่าน the current descriptor ที่ชี้ไปโดย the ETH_DMACHRDR register. ถ้า descriptor นั้นไม่มีให้ใช้งาน (ถูกเป็นเจ้าของโดย Host), reception กลับคืนสู่ the Suspend state และ ETH_DMASR register bit 7 ไม่ถูกถือสิทธิ์. ถ้า the descriptor มีให้ใช้งาน, the Receive DMA กลับคืนไปยัง active state.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 28, 2021, 10:15:56 AM
Ethernet DMA receive descriptor list address register (ETH_DMARDLAR)

Address offset: 0x100C
Reset value: 0x0000 0000

The Receive descriptor list address register ชี้ไปยังจุดสตาร์ทของ of the receive descriptor list. The descriptor lists อยู่ใน the STM32F107xx's physical memory space และต้องเป็น word-aligned. The DMA จะแปลงมันภายในให้เป็น bus-width aligned address โดยการทำ the corresponding LS bits low. การเขียนไปยัง the ETH_DMARDLAR register ถูกอนุญาติเฉพาะเมื่อ reception ถูกหยุด. เมื่อหยุดแล้ว, the ETH_DMARDLAR register ต้องถูกเขียนถึงก่อน the receive Start command ถูกให้.

(https://i.imgur.com/wyjJYma.png)

Bits 31:0 SRL: Start of receive list
field นี้บรรจุ the base address ของ the first descriptor ใน the receive descriptor list. The LSB bits [1/2/3:0] สำหรับ 32/64/128-bit bus width) ถูกละเว้นภายในและถูกเอามาเป็นศูนย์ทั้งหมดโดย the DMA. ดังนั้น LSB bits เหล่านี้ถูกอ่านได้เพียงอย่างเดียว
Title: Re: STM32F1 ETHERNET
Post by: tha on March 28, 2021, 10:39:19 AM
Ethernet DMA transmit descriptor list address register (ETH_DMATDLAR)

Address offset: 0x1010
Reset value: 0x0000 0000

The Transmit descriptor list address register ชี้ไปยังจุดสตาร์ทของ the Transmit descriptor list. The descriptor lists อยู่ใน the STM32F107xx's physical memory space และต้องเป็น word-aligned. The DMA จะแปลงมันภายในให้เป็น bus-width aligned address โดยการทำ the corresponding LS bits เป็น low. การเขียนไปยัง the ETH_DMATDLAR register ถูกอนุญาติเฉพาะเมื่อ transmission ถูกหยุด. เมื่อ transmission หยุดแล้ว, the ETH_DMATDLAR register สามารถถูกเขียนก่อน the transmission Start command ถูกให้.

(https://i.imgur.com/nB7FHp8.png)

Bits 31:0 STL: Start of transmit list
field นี้บรรจุ the base address ของ the first descriptor ใน the transmit descriptor list. The LSB bits [1/2/3:0] สำหรับ 32/64/128-bit bus width) ถูกละเว้นภายในและถูกเอามาเป็นศูนย์ทั้งหมดโดย the DMA. ดังนั้น LSB bits เหล่านี้ถูกอ่านได้เพียงอย่างเดียว.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 29, 2021, 07:18:57 AM
Ethernet DMA status register (ETH_DMASR)

Address offset: 0x1014
Reset value: 0x0000 0000

The Status register บรรจุ the status bits ทั้งหมดที่ the DMA รายงานถึง the application. The ETH_DMASR register มักจะถูกอ่านโดย the software driver ในระหว่าง an interrupt service routine หรือการวนตรวจ. the fields ส่วนใหญ่ใน register นี้ทำให้ the host ถูก interrupted. The ETH_DMASR register bits ไม่ถูกเคลียร์เมื่อถูกอ่าน. การเขียน 1 ไปยัง (ไม่ได้ถูกสงวนไว้) bits ใน ETH_DMASR register[16:0] จะเคลียร์พวกมันและการเขียน 0 จะไม่มีผลอะไร. แต่ละ field (bits [16:0]) สามารถถูกบังโดยการบัง the appropriate bit ใน the ETH_DMAIER register

(https://i.imgur.com/fOHK1eo.png)

Bits 31:30 Reserved, must be kept at reset value.

Bit 29 TSTS: Time stamp trigger status
บิตนี้แสดงให้เห็น an interrupt event ใน Time stamp generator block ของ the MAC core. The software ต้องอ่าน status register ของ the MAC core, การเคลียร์ source ของมัน (bit 9), เพื่อรีเซ็ตบิตนี้เป็น 0. เมื่อบิตนี้เป็น high, an interrupt ถูกสร้างถ้าเปิดการใช้งาน.

Bit 28 PMTS: PMT status
บิตนี้แสดงให้เห็น an event ใน PMT ของ the MAC core. The software ต้องอ่าน the corresponding registers ใน the MAC core เพื่อให้ได้สาเหตุที่แท้จริงของ interrupt และเคลียร์ source ของมันเพื่อรีเซ็ตบิตนี้เป็น 0. The interrupt ถูกสร้างเมื่อบิตนี้เป็น high ถ้าเปิดการใช้งาน.

Bit 27 MMCS: MMC status
บิตนี้สะท้อน an event ใน the MMC ของ the MAC core. The software ต้องอ่าน the corresponding registers ใน the MAC core เพื่อให้ได้สาเหตุที่แท้จริงของ interrupt และเคลียร์ the source ของ interrupt เพื่อทำบิตนี้เป็น 0. The interrupt ถูกสร้างเมื่อบิตนี้เป็น high ถ้าเปิดการใช้งาน.

Bit 26 Reserved, must be kept at reset value.

Bits 25:23 EBS: Error bits status
บิตเหล่านี้แสดงให้เห็นประเภทของ error ที่ทำให้เกิด a bus error (การตอบสนองข้อผิดพลาดบน the AHB interface). ใช้ได้เฉพาะกับ the fatal bus error bit (ETH_DMASR register [13]) เซ็ต. field นี้ไม่สร้าง an interrupt.
Bit 23 1 Error ในระหว่าง data transfer โดย TxDMA
           0 Error ในระหว่าง data transfer โดย RxDMA
Bit 24 1 Error ในระหว่าง read transfer
           0 Error ในระหว่าง write transfer
Bit 25 1 Error ในระหว่าง descriptor access
           0 Error ในระหว่าง data buffer access
Title: Re: STM32F1 ETHERNET
Post by: tha on March 29, 2021, 08:53:53 AM
Bits 22:20 TPS: Transmit process state
บิตเหล่านี้แสดงให้เห็น the Transmit DMA FSM state. field นี้ไม่สร้าง an interrupt.
     000: Stopped; Reset or Stop Transmit Command ถูกปล่อยออก
     001: Running; กำลังดึง transmit transfer descriptor
     010: Running; กำลังคอยสำหรับ status
     011: Running; กำลังอ่าน Data จาก host memory buffer และจัดคิวมันไปยัง transmit buffer (Tx FIFO)
     100, 101: ถูกสงวนไว้สำหรับใช้ในอนาคต
     110: Suspended; Transmit descriptor ไม่มีให้ใช้งานหรือ transmit buffer underflow
     111: Running; กำลังปิด transmit descriptor

Bits 19:17 RPS: Receive process state
บิตเหล่านี้แสดงให้เห็น the Receive DMA FSM state. field นี้ไม่สร้าง an interrupt.
     000: Stopped: Reset or Stop Receive Command ถูกปล่อยออก
     001: Running: กำลังดึง receive transfer descriptor
     010: ถูกสงวนไว้สำหรับใช้ในอนาคต
     011: Running: กำลังคอยสำหรับ receive packet
     100: Suspended: Receive descriptor ไม่มีให้ใช้งาน
     101: Running: กำลังปิด receive descriptor
     110: ถูกสงวนไว้สำหรับใช้ในอนาคต
     111: Running: กำลังส่งถ่าย the receive packet data จาก receive buffer ไปยัง host memory

Bit 16 NIS: Normal interrupt summary
The normal interrupt summary bit value คือ the logical OR ของสิ่งต่อไปนี้เมื่อ the corresponding interrupt bits ถูกเปิดการใช้งานใน the ETH_DMAIER register:
     – ETH_DMASR [ 0] : Transmit interrupt
     – ETH_DMASR [2] : Transmit buffer unavailable
     – ETH_DMASR [6] : Receive interrupt
     – ETH_DMASR [14] : Early receive interrupt
เฉพาะบิตที่ไม่ถูกบังเท่านั้นที่มีผลต่อ the normal interrupt summary bit.
นี้คือ a sticky bit และมันต้องถูกเคลียร์ (โดยการเขียน 1 ไปยังบิตนี้) แต่ละครั้งที่ a corresponding bit ที่ทำให้ NIS ถูกเซ็ตถูกเคลียร์.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 29, 2021, 10:35:27 AM
Bit 15 AIS: Abnormal interrupt summary
The abnormal interrupt summary bit value คือ the logical OR ของสิ่งต่อไปนี้เมื่อ the corresponding interrupt bits ถูกเปิดการใช้งานใน the ETH_DMAIER register:
     – ETH_DMASR [1]:Transmit process stopped
     – ETH_DMASR [3]:Transmit jabber timeout
     – ETH_DMASR [4]: Receive FIFO overflow
     – ETH_DMASR [5]: Transmit underflow
     – ETH_DMASR [7]: Receive buffer unavailable
     – ETH_DMASR [8]: Receive process stopped
     – ETH_DMASR [9]: Receive watchdog timeout
     – ETH_DMASR [10]: Early transmit interrupt
     – ETH_DMASR [13]: Fatal bus error
เฉพาะบิตที่ไม่ถูกบังเท่านั้นที่มีผลต่อ the abnormal interrupt summary bit.
นี้คือ a sticky bit และมันต้องถูกเคลียร์แต่ละครั้งที่ a corresponding bit ที่ทำให้ AIS ถูกเซ็ตถูกเคลียร์.

Bit 14 ERS: Early receive status
บิตนี้แสดงให้เห็นว่า the DMA ได้เติม the first data buffer ของ the packet. Receive Interrupt ETH_DMASR [6] เคลียร์บิตนี้โดยอัตโนมัติ.

Bit 13 FBES: Fatal bus error status
บิตนี้แสดงให้เห็นว่า a bus error เกิดขึ้น, ดังรายละเอียดใน [25:23]. เมื่อบิตนี้ถูกเซ็ต, the corresponding DMA engine จะปิดการใช้งาน bus accesses ของมันทั้งหมด.

Bits 12:11 Reserved, must be kept at reset value.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 29, 2021, 11:22:15 AM
Bit 10 ETS: Early transmit status
บิตนี้แสดงให้เห็นว่า the frame ที่จะถูกส่งถูกส่งถ่ายไปยัง the Transmit FIFO จนเติมแล้ว.

Bit 9 RWTS: Receive watchdog timeout status
บิตนี้ถูกยืนยันเมื่อ a frame ที่มีความยาวมากกว่า 2 048 bytes ถูกรับ.

Bit 8 RPSS: Receive process stopped status
บิตนี้ถูกยืนยันเมื่อ the receive process เข้าสู่ the Stopped state.

Bit 7 RBUS: Receive buffer unavailable status
บิตนี้แสดงให้เห็นว่า the next descriptor ใน the receive list ถูกเป็นเจ้าของโดย the host และไม่สามารถถูกได้มาโดย the DMA. Receive process ถูกแขวน. เพื่อดำเนินการต่อการประมวลผล receive descriptors, the host ควรเปลี่ยนความเป็นเจ้าของของ the descriptor และปล่อยออก a Receive Poll Demand command. ถ้าไม่มี Receive Poll Demand ถูกปล่อยออก, receive process ดำเนินการต่อเมื่อ the next recognized incoming frame ถูกรับ. ETH_DMASR [7] ถูกเซ็ตเฉพาะเมื่อ the previous receive descriptor เคยถูกเป็นเจ้าของโดย the DMA.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 29, 2021, 12:18:02 PM
Bit 6 RS: Receive status
บิตนี้แสดงให้เห็นการเสร็จสมบูรณ์ของ the frame reception. Specific frame status information ถูกโพสต์ใน the descriptor แล้ว. Reception ยังคงอยู่ใน the Running state.

Bit 5 TUS: Transmit underflow status
บิตนี้แสดงให้เห็นว่า the transmit buffer มี an underflow ในระหว่าง frame transmission. Transmission ถูกแขวนและ an underflow error TDES0[1] ถูกเซ็ต.

Bit 4 ROS: Receive overflow status
บิตนี้แสดงให้เห็นว่า the receive buffer มี an overflow ในระหว่าง frame reception. ถ้า the partial frame ถูกส่งถ่ายไปยัง the application, the overflow status จะถูกเซ็ตใน RDES0[11
Title: Re: STM32F1 ETHERNET
Post by: tha on March 29, 2021, 01:01:46 PM
Bit 3 TJTS: Transmit jabber timeout status
บิตนี้แสดงให้เห็นว่า the transmit jabber timer หมดลง, หมายความว่า the transmitter ถูกทำงานมากเกินไป. The transmission process ถูกยกเลิกและถูกวางใน the Stopped state. สิ่งนี้ทำให้ the transmit jabber timeout TDES0[14] flag ถูกยืนยัน.

Bit 2 TBUS: Transmit buffer unavailable status
บิตนี้แสดงให้เห็นว่า the next descriptor ใน the transmit list ถูกเป็นเจ้าของโดย the host และไม่สามารถถูกได้มาโดย the DMA. Transmission ถูกแขวน. Bits [22:20] อธิบาย the transmit process state transitions. เพื่อดำเนินการต่อการประมวลผล transmit descriptors, the host ควรเปลี่ยนความเป็นเจ้าของของ the bit ของ the descriptor และจากนั้นปล่อยออก a Transmit Poll Demand command.

Bit 1 TPSS: Transmit process stopped status
บิตนี้ถูกเซ็ตเมื่อ the transmission ถูกหยุด.

Bit 0 TS: Transmit status
บิตนี้แสดงให้เห็นว่า that frame transmission ถูกทำเสร็จและ TDES1[31] ถูกเซ็ตใน the first descriptor.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 30, 2021, 07:15:46 AM
Ethernet DMA operation mode register (ETH_DMAOMR)

Address offset: 0x1018
Reset value: 0x0000 0000

The operation mode register สร้าง the Transmit and Receive operating modes และคำสั่ง. The ETH_DMAOMR register ควรเป็น the last CSR ที่จะถูกเขียนเป็นส่วนหนึ่งของ DMA initialization.

(https://i.imgur.com/ebBotpT.png)

Bits 31:27 Reserved, must be kept at reset value.

Bit 26 DTCEFD: Dropping of TCP/IP checksum error frames disable
เมื่อบิตนี้ถูกเซ็ต, the core จะไม่ดร็อป frames ที่มีเพียง errors ที่ตรวจพบโดย the receive checksum offload engine. frames ดังกล่าวไม่มี errors ใดๆ (รวมถึง FCS error) ใน the Ethernet frame ที่รับโดย the MAC แต่มี errors ใน the encapsulated payload เท่านั้น. เมื่อบิตนี้ถูกเคลียร์, error frames ทั้งหมดถูกดร็อปถ้า the FEF bit ถูกรีเซ็ต.

Bit 25 RSF: Receive store and forward
เมื่อบิตนี้ถูกเซ็ต, a frame ถูกอ่านจาก the Rx FIFO หลังจาก the complete frame ถูกเขียนไปยังมัน, โดยไม่สนใจ RTC bits. เมื่อบิตนี้ถูกเคลียร์, the Rx FIFO จะทำงานใน Cut-through mode, ขึ้นอยู่กับขีดจำกัดที่ระบุโดย the RTC bits.

Bit 24 DFRF: Disable flushing of received frames
เมื่อบิตนี้ถูกเซ็ต, the RxDMA จะไม่ล้าง frames ใดๆเนื่องจากการไม่มีให้ใช้งานของ receive descriptors/buffers ตามปกติเมื่อบิตนี้ถูกเคลียร์ (ดู Receive process suspended).

Bits 23:22 Reserved, must be kept at reset value.

Bit 21 TSF: Transmit store and forward
เมื่อบิตนี้ถูกเซ็ต, transmission สตาร์ทเมื่อ a full frame มีอยู่ใน the Transmit FIFO.
เมื่อบิตนี้ถูกเซ็ต, the TTC values ที่ระบุโดย the ETH_DMAOMR register bits [16:14] จะถูกไม่สนใจ.
เมื่อบิตนี้ถูกเคลียร์, the TTC values ที่ระบุโดย the ETH_DMAOMR register bits [16:14] จะถูกคำนึงถึง.
บิตนี้ควรถูกเปลี่ยนเฉพาะเมื่อ transmission ถูกหยุด.

Bit 20 FTF: Flush transmit FIFO
เมื่อบิตนี้ถูกเซ็ต, the transmit FIFO controller logic ถูกรีเซ็ตเป็นค่าเริ่มต้นของมันและดังนั้น data ทั้งหมดใน the Tx FIFO จะสูญหาย/ถูกล้าง. บิตนี้ถูกเคลียร์ภายในเมื่อ the flushing operation เสร็จสมบูรณ์. The Operation mode register ไม่ควรถูกเขียนถึงจนกระทั่งบิตนี้ถูกเคลียร์.

Bits 19:17 Reserved, must be kept at reset value.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 30, 2021, 09:34:55 AM
Bits 16:14 TTC: Transmit threshold control
สามบิตเหล่านี้ควบคุมระดับขีดจำกัดของ the Transmit FIFO. Transmission สตาร์ทเมื่อ the frame size ถายใน the Transmit FIFO ใหญ่กว่า the threshold. นอกจากนี้, full frames ที่มีความยาวน้อยกว่า the threshold ถูกส่งอีกด้วย. บิตเหล่านี้ถูกใช้เฉพาะเมื่อ the TSF bit (Bit 21) ถูกเคลียร์.
     000: 64
     001: 128
     010: 192
     011: 256
     100: 40
     101: 32
     110: 24
     111: 16

Bit 13 ST: Start/stop transmission
เมื่อบิตนี้ถูกเซ็ต, transmission ถูกวางใน the Running state, และ the DMA ตรวจสอบ the transmit list ที่ตำแหน่งปัจจุบันสำหรับ a frame ที่จะถูกส่ง. Descriptor acquisition ถูกพยายามอย่างใดอย่างหนึ่งจาก the current position ใน the list, ซึ่งเป็น the transmit list base address ที่เซ็ตโดย the ETH_DMATDLAR register, หรือจากตำแหน่งที่ถูกเก็บไว้เมื่อ transmission ถูกหยุดไปก่อนหน้านี้. ถ้า the current descriptor ไม่ถูกเป็นเจ้าของโดย the DMA, transmission จะเข้าสู่ the Suspended state และ the transmit buffer unavailable bit (ETH_DMASR [2]) ถูกเซ็ต. The Start Transmission command มีผลเฉพาะเมื่อ transmission ถูกหยุด. ถ้า the command ถูกปล่อยออกก่อนการเซ็ต the DMA ETH_DMATDLAR register, the DMA behavior จะคาดการณ์ไม่ได้.
เมื่อบิตนี้ถูกเคลียร์, the transmission process ถูกวางใน the Stopped state หลังจากการเสร็จสมบูรณ์ the transmission ของ the current frame. The next descriptor position ใน the transmit list จะถูกบันทึก, และกลายมาเป็น the current position เมื่อ transmission ถูกรีสตาร์ท. The Stop Transmission command มีผลเฉพาะเมื่อ the transmission ของ the current frame เสร็จ
สมบูรณ์หรือเมื่อ the transmission อยู่ใน the Suspended state.

Bits 12:8 Reserved, must be kept at reset value.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 30, 2021, 10:36:35 AM
Bit 7 FEF: Forward error frames
เมื่อบิตนี้ถูกเซ็ต, frames ทั้งหมดยกเว้น runt error frames ถูกส่งต่อไปยัง the DMA.
เมื่อบิตนี้ถูกเคลียร์, the Rx FIFO ดร็อป frames ที่มี error status (CRC error, collision error, giant frame, watchdog timeout, overflow). อย่างไรก็ตาม, ถ้า the frame's start byte (write) pointer ถูกส่งถ่ายไปยัง the read controller side แล้ว (ใน Threshold mode), ดังนั้น the frames จะไม่ถูกดร็อป. The Rx FIFO ดร็อป the error frames ถ้า start byte ของ frame นั้น ไม่ถูกส่งถ่าย (output) บน the ARI bus.

Bit 6 FUGF: Forward undersized good frames
เมื่อบิตนี้ถูกเซ็ต, the Rx FIFO ส่งต่อ undersized frames (frames ที่ไม่มี error และมีความยาวน้อยกว่า 64 bytes) รวมทั้ง pad-bytes และ CRC).
เมื่อบิตนี้ถูกเคลียร์, the Rx FIFO ดร็อปทุก frames ที่น้อยกว่า 64 bytes, เว้นแต่ a frame ดังกล่าวถูกส่งถ่ายแล้วเนื่องจากค่าที่ต่ำกว่าของ receive threshold (เช่น, RTC = 01).

Bit 5 Reserved, must be kept at reset value.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 30, 2021, 11:45:25 AM
Bits 4:3 RTC: Receive threshold control
สองบิตเหล่านี้ควบคุมระดับขีดจำกัดของ the Receive FIFO. Transfer (ร้องขอ) ไปยัง DMA สตาร์ทเมื่อ the frame size ภายใน the Receive FIFO ใหญ่กว่า the threshold. นอกจากนี้, full frames ที่มีความยาวน้อยกว่า the threshold จะถูกส่งถ่ายโดยอัตโนมัติ.
Note: โปรดทราบว่าค่า 11 ไม่สามารถใช้ได้ถ้า the configured Receive FIFO size เป็น 128 bytes.
Note: บิตเหล่านี้ใช้ได้เฉพาะเมื่อ the RSF bit เป็นศูนย์, และถูกไม่สนใจเมื่อ the RSF bit ถูกเซ็ตเป็น 1.

     00: 64
     01: 32
     10: 96
     11: 128

Bit 2 OSF: Operate on second frame
เมื่อบิตนี้ถูกเซ็ต, บิตนี้สั่งให้ the DMA ประมวลผล a second frame ของ Transmit data แม้ก่อน status สำหรับ first frame ถูกได้รับ.

Bit 1 SR: Start/stop receive
เมื่อบิตนี้ถูกเซ็ต, the receive process ถูกวางใน the Running state. The DMA พยายามให้ได้มา the descriptor จาก the receive list และประมวลผล incoming frames. Descriptor acquisition ถูกพยายามจาก the current position ใน the list, ซึ่งเป็น the address ที่ถูกเซ็ตโดย the DMA ETH_DMARDLAR register หรือตำแหน่งที่ถูกเก็บไว้เมื่อ the receive process ที่ถูกหยุดไปก่อนหน้านี้. ถ้าไม่มี descriptor ถูกเป็นเจ้าของโดย the DMA, reception จะถูกแขวนและ the receive buffer unavailable bit (ETH_DMASR [7]) ถูกเซ็ต. The Start Receive command มีผลเฉพาะเมื่อ reception ได้หยุดลงแล้ว. ถ้า the command ถูกปล่อยออกไปแล้วก่อนการเซ็ต the DMA ETH_DMARDLAR register, the DMA behavior จะคาดการณ์ไม่ได้.
เมื่อบิตนี้ถูกเคลียร์, RxDMA operation ถูกหยุดหลังจากการส่งถ่ายของ the current frame. The next descriptor position ใน the receive list ถูกบันทึกและกลายมาเป็น the current position เมื่อ the receive process ถูกรีสตาร์ท. The Stop Receive command มีผลเฉพาะเมื่อ the Receive process อยู่ในอย่างใดอย่างหนึ่ง the Running (กำลังคอยสำหรับ receive packet) หรือ the Suspended state.

Bit 0 Reserved, must be kept at reset value
Title: Re: STM32F1 ETHERNET
Post by: tha on March 31, 2021, 07:44:18 AM
Ethernet DMA interrupt enable register (ETH_DMAIER)

Address offset: 0x101C
Reset value: 0x0000 0000

The Interrupt enable register เปิดการใช้งาน the interrupts ที่ถูกรายงานโดย ETH_DMASR. การเซ็ต a bit เป็น 1 เปิดการใช้งาน a corresponding interrupt. หลังจาก a hardware หรือ software รีเซ็ต, interrupts ทั้งหมดถูกปิดการใช้งาน.

(https://i.imgur.com/qCRLYa6.png)

Bits 31:17 Reserved, must be kept at reset value.

Bit 16 NISE: Normal interrupt summary enable
เมื่อบิตนี้ถูกเซ็ต, a normal interrupt ถูกเปิดการใช้งาน. เมื่อบิตนี้ถูกเคลียร์, a normal interrupt ถูกปิดการใช้งาน. บิตนี้เปิดการใช้งานบิตต่อไปนี้ :
     – ETH_DMASR [ 0]: Transmit Interrupt
     – ETH_DMASR [2]: Transmit buffer unavailable
     – ETH_DMASR [6]: Receive interrupt
     – ETH_DMASR [14]: Early receive interrupt

Bit 15 AISE: Abnormal interrupt summary enable
เมื่อบิตนี้ถูกเซ็ต, a abnormal interrupt ถูกเปิดการใช้งาน. เมื่อบิตนี้ถูกเคลียร์, a abnormal interrupt ถูกปิดการใช้งาน. บิตนี้เปิดการใช้งานบิตต่อไปนี้ :
     – ETH_DMASR [1]: Transmit process stopped
     – ETH_DMASR [3]: Transmit jabber timeout
     – ETH_DMASR [4]: Receive overflow
     – ETH_DMASR [5]: Transmit underflow
     – ETH_DMASR [7]: Receive buffer unavailable
     – ETH_DMASR [8]: Receive process stopped
     – ETH_DMASR [9]: Receive watchdog timeout
     – ETH_DMASR [10]: Early transmit interrupt
     – ETH_DMASR [13]: Fatal bus error

Bit 14 ERIE: Early receive interrupt enable
เมื่อบิตนี้ถูกเซ็ตพร้อมกับ the normal interrupt summary enable bit (ETH_DMAIER register[16]), the early receive interrupt ถูกเปิดการใช้งาน.
เมื่อบิตนี้ถูกเคลียร์, the early receive interrupt ถูกปิดการใช้งาน.

Bit 13 FBEIE: Fatal bus error interrupt enable
เมื่อบิตนี้ถูกเซ็ตพร้อมกับ the abnormal interrupt summary enable bit (ETH_DMAIER register[15]), the fatal bus error interrupt ถูกเปิดการใช้งาน.
เมื่อบิตนี้ถูกเคลียร์, the fatal bus error enable interrupt ถูกปิดการใช้งาน.

Bits 12:11 Reserved, must be kept at reset value.

Bit 10 ETIE: Early transmit interrupt enable
เมื่อบิตนี้ถูกเซ็ตพร้อมกับ the abnormal interrupt summary enable bit (ETH_DMAIER register [15]), the early transmit interrupt ถูกเปิดการใช้งาน.
เมื่อบิตนี้ถูกเคลียร์, the early transmit interrupt ถูกปิดการใช้งาน.

Bit 9 RWTIE: receive watchdog timeout interrupt enable
เมื่อบิตนี้ถูกเซ็ตพร้อมกับ the abnormal interrupt summary enable bit (ETH_DMAIER register[15]), the receive watchdog timeout interrupt ถูกเปิดการใช้งาน.
เมื่อบิตนี้ถูกเคลียร์, the receive watchdog timeout interrupt ถูกปิดการใช้งาน.

Bit 8 RPSIE: Receive process stopped interrupt enable
เมื่อบิตนี้ถูกเซ็ตพร้อมกับ the abnormal interrupt summary enable bit (ETH_DMAIER register[15]), the receive stopped interrupt ถูกเปิดการใช้งาน.
เมื่อบิตนี้ถูกเคลียร์, the receive stopped interrupt ถูกปิดการใช้งาน.

Bit 7 RBUIE: Receive buffer unavailable interrupt enable
เมื่อบิตนี้ถูกเซ็ตพร้อมกับ the abnormal interrupt summary enable bit (ETH_DMAIER register[15]), the receive buffer unavailable interrupt ถูกเปิดการใช้งาน.
เมื่อบิตนี้ถูกเคลียร์, the receive buffer unavailable interrupt ถูกปิดการใช้งาน.

Bit 6 RIE: Receive interrupt enable
เมื่อบิตนี้ถูกเซ็ตพร้อมกับ the normal interrupt summary enable bit (ETH_DMAIER register[16]), the receive interrupt ถูกเปิดการใช้งาน.
เมื่อบิตนี้ถูกเคลียร์, the receive interrupt ถูกปิดการใช้งาน.

Bit 5 TUIE: Underflow interrupt enable
เมื่อบิตนี้ถูกเซ็ตพร้อมกับ the abnormal interrupt summary enable bit (ETH_DMAIER register[15]), the transmit underflow interrupt ถูกเปิดการใช้งาน.
เมื่อบิตนี้ถูกเคลียร์, the underflow interrupt ถูกปิดการใช้งาน.

Bit 4 ROIE: Overflow interrupt enable
เมื่อบิตนี้ถูกเซ็ตพร้อมกับ the abnormal interrupt summary enable bit (ETH_DMAIER register[15]), the receive overflow interrupt ถูกเปิดการใช้งาน.
เมื่อบิตนี้ถูกเคลียร์, the overflow interrupt ถูกปิดการใช้งาน.

Bit 3 TJTIE: Transmit jabber timeout interrupt enable
เมื่อบิตนี้ถูกเซ็ตพร้อมกับ the abnormal interrupt summary enable bit (ETH_DMAIER register[15]), the transmit jabber timeout interrupt ถูกเปิดการใช้งาน.
เมื่อบิตนี้ถูกเคลียร์, the transmit jabber timeout interrupt ถูกปิดการใช้งาน.

Bit 2 TBUIE: Transmit buffer unavailable interrupt enable
เมื่อบิตนี้ถูกเซ็ตพร้อมกับ the normal interrupt summary enable bit (ETH_DMAIER register[16]), the transmit buffer unavailable interrupt ถูกเปิดการใช้งาน.
เมื่อบิตนี้ถูกเคลียร์, the transmit buffer unavailable interrupt ถูกปิดการใช้งาน.

Bit 1 TPSIE: Transmit process stopped interrupt enable
เมื่อบิตนี้ถูกเซ็ตพร้อมกับ the abnormal interrupt summary enable bit (ETH_DMAIER register[15]), the transmission stopped interrupt ถูกเปิดการใช้งาน.
เมื่อบิตนี้ถูกเคลียร์, the transmission stopped interrupt ถูกปิดการใช้งาน.

Bit 0 TIE: Transmit interrupt enable
เมื่อบิตนี้ถูกเซ็ตพร้อมกับ the normal interrupt summary enable bit (ETH_DMAIER register[16]), the transmit interrupt ถูกเปิดการใช้งาน.
เมื่อบิตนี้ถูกเคลียร์, the transmit interrupt ถูกปิดการใช้งาน.

The Ethernet interrupt ถูกสร้างเฉพาะเมื่อ the TSTS หรือ PMTS bits ของ the DMA Status register ถูกยืนยันพร้อมด้วย corresponding interrupt ของพวกมันไม่ถูกบัง, หรือเมื่อ the NIS/AIS Status bit ถูกยืนยันและ the corresponding Interrupt Enable bits (NISE/AISE) ถูกเปิดการใช้งาน
Title: Re: STM32F1 ETHERNET
Post by: tha on March 31, 2021, 08:31:43 AM
Ethernet DMA missed frame and buffer overflow counter register (ETH_DMAMFBOCR)

Address offset: 0x1020
Reset value: 0x0000 0000

The DMA ค้ำจุน two counters เพื่อติดตามจำนวนของ missed frames ในระหว่าง reception. register นี้รายงาน the current value ของ the counter. The counter ถูกใช้สำหรับ diagnostic purposes. Bits [15:0] แสดงให้เห็น missed frames เนื่องจาก the STM32F107xx buffer ไม่มีให้ใช้งาน (ไม่มี receive descriptor ให้ใช้งาน). Bits [27:17] แสดงให้เห็น missed frames เนื่องจาก Rx FIFO overflow conditions และ runt frames (good frames ที่น้อยกว่า 64 bytes).

(https://i.imgur.com/xzi2Gji.png)

Bits 31:29 Reserved, must be kept at reset value.

Bit 28 OFOC: Overflow bit for FIFO overflow counter

Bits 27:17 MFA: Missed frames by the application
แสดงให้เห็นจำนวนของ frames ที่พลาดโดย the application

Bit 16 OMFC: Overflow bit for missed frame counter

Bits 15:0 MFC: Missed frames by the controller
แสดงให้เห็นจำนวนของ frames ที่พลาดโดย the Controller เนื่องจาก the host receive buffer ไม่พร้อมให้ใช้งาน. counter นี้ถูกเพิ่มแต่ละครั้งที่ the DMA ละทิ้ง an incoming frame.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 31, 2021, 09:18:16 AM
Ethernet DMA current host transmit descriptor register (ETH_DMACHTDR)

Address offset: 0x1048
Reset value: 0x0000 0000

The Current host transmit descriptor register ชี้ไปยัง the start address ของ the current transmit descriptor ที่ถูกอ่านโดย the DMA.

(https://i.imgur.com/8B0b89G.png)

Bits 31:0 HTDAP: Host transmit descriptor address pointer
Cleared . Pointer ที่ถูกอัปเดตโดย DMA ในระหว่าง operation.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 31, 2021, 09:25:26 AM
Ethernet DMA current host receive descriptor register (ETH_DMACHRDR)

Address offset: 0x104C
Reset value: 0x0000 0000

The Current host receive descriptor register ชี้ไปยัง the start address ของ the current receive descriptor ที่ถูกอ่านโดย the DMA

(https://i.imgur.com/n2JMazV.png)

Bits 31:0 HRDAP: Host receive descriptor address pointer
Cleared On Reset. Pointer ที่ถูกอัปเดตโดย DMA ในระหว่าง operation.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 31, 2021, 09:56:19 AM
Ethernet DMA current host transmit buffer address register (ETH_DMACHTBAR)

Address offset: 0x1050
Reset value: 0x0000 0000

The Current host transmit buffer address register ชี้ไปยัง the current transmit buffer address กำลังถูกอ่านโดย the DMA.

(https://i.imgur.com/hUPdUWD.png)

Bits 31:0 HTBAP: Host transmit buffer address pointer
Cleared On Reset. Pointer ที่ถูกอัปเดตโดย DMA ในระหว่าง operation.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 31, 2021, 10:02:19 AM
Ethernet DMA current host receive buffer address register (ETH_DMACHRBAR)

Address offset: 0x1054
Reset value: 0x0000 0000

The current host receive buffer address register ชี้ไปยัง the current receive buffer address กำลังถูกอ่านโดย the DMA.

(https://i.imgur.com/EB9CNKB.png)

Bits 31:0 HRBAP: Host receive buffer address pointer
Cleared On Reset. Pointer ที่ถูกอัปเดตโดย DMA ในระหว่าง operation.
Title: Re: STM32F1 ETHERNET
Post by: tha on March 31, 2021, 10:12:45 AM
29.8.5 Ethernet register maps

Table 218 ให้ the ETH register map และ reset values.

(https://i.imgur.com/5Gt8NWX.png)

(https://i.imgur.com/fQSFym6.png)

(https://i.imgur.com/zjqoyAx.png)

(https://i.imgur.com/TXqElHA.png)
Title: Re: STM32F1 ETHERNET
Post by: tha on March 31, 2021, 10:19:52 AM
-