STM32F1 ETHERNET

Started by tha, February 11, 2021, 08:40:30 AM

Previous topic - Next topic

tha

SMI frame format

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



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.

tha

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.



tha

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.




tha

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.


tha

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.



•    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

tha

•    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.




tha

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.


tha