Wiznet makers

gavinchang

Published June 27, 2026 ©

101 UCC

25 WCC

68 VAR

0 Contests

4 Followers

0 Following

Original Link

How to Learn Ethernet Registers with WIZnet W5500 on MicroPython MCU Boards?

This education-focused project explains how MicroPython MCU boards can use WIZnet W5500 to learn wired Ethernet through real register-level behavior.

COMPONENTS
PROJECT DESCRIPTION

How to Learn Ethernet Registers with WIZnet W5500 on MicroPython MCU Boards?

Summary

This education-focused project explains how MicroPython MCU boards can use WIZnet W5500 to learn wired Ethernet through real register-level behavior. The original CSDN Wenku answer page could not be directly fetched during verification, so project-specific code from that exact page is not quoted. Verified related sources show the same practical teaching path: connect W5500 to an MCU over SPI, inspect common registers such as MAC, IP, subnet, gateway, PHY status, and chip version, then observe socket registers while running TCP or UDP communication. W5500 acts as the Ethernet MAC/PHY, hardwired TCP/IP engine, socket controller, and packet-buffer manager.

What the Project Does

The project is a classroom or lab exercise for understanding how a hardware TCP/IP Ethernet controller works under MicroPython. Instead of treating networking as a black-box library call, students can inspect the W5500 register map and see how network identity, link status, socket mode, socket state, TX free space, and RX received size are represented in firmware.

A practical lab flow is:

MicroPython script → W5500 driver → SPI transaction → W5500 common/socket registers → Ethernet cable → router, PC, or local test server.

A related CSDN MicroPython example uses an ESP32-C3 board, a W5500 wired Ethernet UDP/TCP module, jumper wires, and a Windows PC. It explains that W5500 is connected to the development board through SPI, while the W5500 LAN port is connected to a router so the PC and W5500 are on the same network segment.

This is useful for education because students can connect abstract network concepts to concrete registers. Gateway address is not just a configuration field; it is stored in GAR. The subnet mask is stored in SUBR. The local MAC address is stored in SHAR. The local IP address is stored in SIPR. Link state, speed, and duplex can be read through PHYCFGR. Socket behavior can be followed through socket mode, command, status, TX free-size, and RX received-size registers.

Where WIZnet Fits

The exact WIZnet product is W5500. It sits between the MicroPython MCU and the RJ45 Ethernet interface. The MCU sends register and buffer transactions over SPI; W5500 handles Ethernet MAC/PHY operation, hardwired TCP/IP processing, socket state, and packet buffering.

WIZnet documents W5500 as a hardwired TCP/IP controller with SPI access up to 80 MHz, an embedded 10/100 Ethernet MAC and PHY, support for TCP, UDP, ICMP, IPv4, ARP, IGMP, and PPPoE, 8 independent sockets, and 32 KB internal memory for Tx/Rx buffers.

For register education, W5500 is a good fit because it exposes a clean boundary. The MCU is not just calling a hidden network stack. It can write common registers for network identity, read PHY status, open sockets, check socket status, and move data through TX/RX buffers. The W5500 datasheet describes the register and memory organization as one common register block, eight socket register blocks, and TX/RX buffer blocks allocated to each socket.

Implementation Notes

The exact Wenku page did not expose verified source files or a public repository. The snippets below are from verified related W5500 MicroPython sources and should be treated as reference patterns, not as code proven to come from the exact Wenku answer page.

File: wiznet5k.py
What it configures: W5500 common registers and socket registers used for network identity, chip detection, PHY status, and socket operation.
Why it matters: these constants are the register vocabulary students need before they can reason about Ethernet behavior at the device level.

 
REG_MR = const(0x0000) # Mode
REG_GAR = const(0x0001) # Gateway IP Address
REG_SUBR = const(0x0005) # Subnet Mask Address
REG_VERSIONR_W5500 = const(0x0039) # W5500 Silicon Version
REG_SHAR = const(0x0009) # Source Hardware Address
REG_SIPR = const(0x000F) # Source IP Address
REG_PHYCFGR = const(0x002E) # W5500 PHY Configuration

REG_SNMR = const(0x0000) # Socket n Mode
REG_SNCR = const(0x0001) # Socket n Command
REG_SNSR = const(0x0003) # Socket n Status
REG_SNRX_RSR = const(0x0026) # RX Free Size
REG_SNTX_FSR = const(0x0020) # Socket n TX Free Size
 

This register set appears in the related MicroPython W5500 driver source. The same file is marked with SPDX-License-Identifier: MIT, and the repository README states that the project is licensed under the MIT License.

File: wiznet5k.py
What it configures: W5500 chip detection and software reset through the mode register and version register.
Why it matters: before teaching TCP or UDP, students should prove that SPI transactions are reaching the chip and that the controller reports the expected W5500 version.

 
def detect_w5500(self):
    """Detects W5500 chip."""
    assert self.sw_reset() == 0, "Chip not reset properly!"
    self._write_mr(0x08)
    assert self._read_mr()[0] == 0x08, "Expected 0x08."
    self._write_mr(0x10)
    assert self._read_mr()[0] == 0x10, "Expected 0x10."
    self._write_mr(0x00)
    assert self._read_mr()[0] == 0x00."
    if self.read(REG_VERSIONR_W5500, 0x00)[0] != 0x04:
        return -1
 

This sequence exists to validate the register path before higher-level networking begins. It writes test values into the mode register, reads them back, clears the mode register, and then checks the W5500 version register.

Practical Tips / Pitfalls

  • Start the lab with register reads, not HTTP. Confirm REG_VERSIONR_W5500 and REG_PHYCFGR before opening sockets.
  • Keep SPI wiring short and stable. Register read failures often come from SCLK, chip select, or ground problems.
  • Teach common registers before socket registers. MAC, IP, subnet, gateway, and PHY status are easier to understand than the socket state machine.
  • Use UDP before TCP. UDP makes TX/RX buffer movement easier to observe without connection-state complexity.
  • Log Sn_SR, Sn_TX_FSR, and Sn_RX_RSR during each send/receive exercise.
  • Route reset to the MCU so students can recover the chip without power-cycling the whole board.

FAQ

Q: Why use WIZnet W5500 for register-level Ethernet education?
A: W5500 exposes a practical hardware boundary between the MCU and Ethernet networking. Students can inspect common registers, socket registers, PHY status, and buffer counters while still using a real hardwired TCP/IP controller with 8 sockets and 32 KB internal Tx/Rx memory.

Q: How does W5500 connect to the MicroPython platform?
A: W5500 connects through SPI using MOSI, MISO, SCLK, chip select, reset, 3.3 V, and ground. MicroPython’s WIZNET5K documentation describes the control model as an SPI object plus chip-select and reset pins, and its example connection list includes MOSI, MISO, SCLK, nSS, and nRESET.

Q: What role does W5500 play in this education project?
A: W5500 is the register-visible Ethernet engine. The MicroPython board sends SPI register commands, while W5500 manages the Ethernet MAC/PHY, hardwired TCP/IP behavior, socket states, and TX/RX buffers.

Q: Can beginners follow this project?
A: Yes, if the lesson is staged. The recommended order is SPI wiring, version-register read, PHY status read, MAC/IP/subnet/gateway register review, UDP socket test, socket status logging, then TCP connection behavior.

Q: How is this different from teaching networking over Wi-Fi?
A: Wi-Fi is convenient for application-level networking, but it usually hides the lower interface state behind a driver. W5500 makes the Ethernet controller visible through registers, so students can observe link status, socket states, and buffer counters directly. That makes it better for teaching how an embedded network controller actually behaves.

Source

Original source: CSDN Wenku answer page provided by the user. The page could not be directly fetched during verification, so its license and project-specific implementation details could not be confirmed.
https://wenku.csdn.net/answer/nk9zgniwyq

Related CSDN source: “Micropython ESP32 C3连接W5500有线以太网UDP&TCP协议通讯模块,” which includes ESP32-C3 + W5500 environment details, SPI connection context, register constants, chip detection logic, and UDP/TCP example material. The page states that it follows the CC 4.0 BY-SA license.

Related implementation reference: Ayyoubzadeh/ESP32-Wiznet-W5500-Micropython, an MIT-licensed ESP32 + W5500 MicroPython repository containing wiznet5k.py, DHCP, DNS, socket, and request helper files.

WIZnet product reference: W5500 documentation and feature list.

MicroPython reference: WIZNET5K documentation for WIZnet5x00 Ethernet modules.

Tags

#W5500 #WIZnet #MicroPython #Education #Ethernet #SPI #Registers #WIZNET5K #Firmware #Socket #UDP #TCP #PHY #EmbeddedNetworking

 

MicroPython MCU 보드에서 WIZnet W5500으로 Ethernet Register를 학습하는 방법은?

요약

이 교육용 프로젝트는 MicroPython MCU 보드가 WIZnet W5500을 사용해 실제 register-level 동작을 통해 유선 Ethernet을 학습하는 방법을 설명합니다. 원본 CSDN Wenku answer page는 검증 중 직접 가져올 수 없었으므로, 해당 페이지의 프로젝트별 코드는 인용하지 않습니다. 검증된 관련 자료는 동일한 실습 방향을 보여줍니다. W5500을 SPI로 MCU에 연결하고, MAC, IP, subnet, gateway, PHY status, chip version 같은 common register를 확인한 뒤, TCP 또는 UDP 통신 중 socket register를 관찰하는 방식입니다. W5500은 Ethernet MAC/PHY, hardwired TCP/IP engine, socket controller, packet-buffer manager 역할을 합니다.

프로젝트가 하는 일

이 프로젝트는 hardware TCP/IP Ethernet controller가 MicroPython 환경에서 어떻게 동작하는지 이해하기 위한 classroom 또는 lab exercise입니다. Networking을 black-box library call로만 다루는 대신, 학생들은 W5500 register map을 살펴보고 network identity, link status, socket mode, socket state, TX free space, RX received size가 firmware에서 어떻게 표현되는지 확인할 수 있습니다.

실용적인 lab flow는 다음과 같습니다.

MicroPython script → W5500 driver → SPI transaction → W5500 common/socket register → Ethernet cable → router, PC 또는 local test server

관련 CSDN MicroPython 예제는 ESP32-C3 board, W5500 wired Ethernet UDP/TCP module, jumper wire, Windows PC를 사용합니다. 이 예제는 W5500이 SPI를 통해 development board에 연결되고, W5500 LAN port가 router에 연결되어 PC와 W5500이 같은 network segment에 위치하도록 구성된다고 설명합니다.

이 구조는 교육에 유용합니다. 학생들이 추상적인 network concept을 구체적인 register와 연결할 수 있기 때문입니다. Gateway address는 단순한 설정값이 아니라 GAR에 저장됩니다. Subnet mask는 SUBR에 저장됩니다. Local MAC address는 SHAR에 저장됩니다. Local IP address는 SIPR에 저장됩니다. Link state, speed, duplex는 PHYCFGR를 통해 읽을 수 있습니다. Socket behavior는 socket mode, command, status, TX free-size, RX received-size register를 통해 추적할 수 있습니다.

WIZnet이 들어가는 위치

이 프로젝트에서 사용되는 정확한 WIZnet 제품은 W5500입니다. W5500은 MicroPython MCU와 RJ45 Ethernet interface 사이에 위치합니다. MCU는 SPI를 통해 register 및 buffer transaction을 전송하고, W5500은 Ethernet MAC/PHY operation, hardwired TCP/IP processing, socket state, packet buffering을 처리합니다.

WIZnet 문서 기준으로 W5500은 최대 80 MHz SPI access, embedded 10/100 Ethernet MAC and PHY, TCP, UDP, ICMP, IPv4, ARP, IGMP, PPPoE 지원, 8개 independent socket, Tx/Rx buffer용 32 KB internal memory를 제공하는 hardwired TCP/IP controller입니다.

Register 교육에서 W5500이 적합한 이유는 경계가 명확하기 때문입니다. MCU는 숨겨진 network stack을 호출하는 것에 그치지 않습니다. Common register에 network identity를 쓰고, PHY status를 읽고, socket을 열고, socket status를 확인하며, TX/RX buffer를 통해 data를 이동할 수 있습니다. W5500 datasheet는 register 및 memory organization을 하나의 common register block, 8개의 socket register block, 각 socket에 할당되는 TX/RX buffer block으로 설명합니다.

구현 참고 사항

정확한 Wenku page는 검증 가능한 source file이나 public repository를 노출하지 않았습니다. 아래 snippet은 검증된 관련 W5500 MicroPython 자료에서 가져온 reference pattern이며, 정확한 Wenku answer page의 코드로 입증된 것은 아닙니다.

파일: wiznet5k.py
설정 내용: network identity, chip detection, PHY status, socket operation에 사용되는 W5500 common register 및 socket register
중요한 이유: 이 constant들은 학생들이 device level에서 Ethernet behavior를 이해하기 전에 먼저 알아야 하는 register vocabulary입니다.

 
REG_MR = const(0x0000) # Mode
REG_GAR = const(0x0001) # Gateway IP Address
REG_SUBR = const(0x0005) # Subnet Mask Address
REG_VERSIONR_W5500 = const(0x0039) # W5500 Silicon Version
REG_SHAR = const(0x0009) # Source Hardware Address
REG_SIPR = const(0x000F) # Source IP Address
REG_PHYCFGR = const(0x002E) # W5500 PHY Configuration

REG_SNMR = const(0x0000) # Socket n Mode
REG_SNCR = const(0x0001) # Socket n Command
REG_SNSR = const(0x0003) # Socket n Status
REG_SNRX_RSR = const(0x0026) # RX Free Size
REG_SNTX_FSR = const(0x0020) # Socket n TX Free Size
 

이 register set은 관련 MicroPython W5500 driver source에 등장합니다. 같은 파일은 SPDX-License-Identifier: MIT로 표시되어 있으며, repository README는 해당 프로젝트가 MIT License를 따른다고 명시합니다.

파일: wiznet5k.py
설정 내용: mode register와 version register를 통한 W5500 chip detection 및 software reset
중요한 이유: TCP 또는 UDP를 가르치기 전에, 학생들은 SPI transaction이 chip에 도달하고 controller가 기대한 W5500 version을 보고하는지 확인해야 합니다.

 
def detect_w5500(self):
    """Detects W5500 chip."""
    assert self.sw_reset() == 0, "Chip not reset properly!"
    self._write_mr(0x08)
    assert self._read_mr()[0] == 0x08, "Expected 0x08."
    self._write_mr(0x10)
    assert self._read_mr()[0] == 0x10, "Expected 0x10."
    self._write_mr(0x00)
    assert self._read_mr()[0] == 0x00."
    if self.read(REG_VERSIONR_W5500, 0x00)[0] != 0x04:
        return -1
 

이 sequence는 higher-level networking을 시작하기 전에 register path를 검증하기 위해 존재합니다. Mode register에 test value를 쓰고 다시 읽은 뒤, mode register를 clear하고 W5500 version register를 확인합니다.

실무 팁 / 주의점

  • Lab은 HTTP가 아니라 register read부터 시작하는 것이 좋습니다. Socket을 열기 전에 REG_VERSIONR_W5500REG_PHYCFGR를 확인해야 합니다.
  • SPI wiring은 짧고 안정적으로 유지해야 합니다. Register read failure는 SCLK, chip select, ground 문제에서 자주 발생합니다.
  • Socket register보다 common register를 먼저 가르치는 것이 좋습니다. MAC, IP, subnet, gateway, PHY status는 socket state machine보다 이해하기 쉽습니다.
  • TCP보다 UDP를 먼저 사용하는 것이 좋습니다. UDP는 connection-state complexity 없이 TX/RX buffer movement를 관찰하기 쉽습니다.
  • 각 send/receive exercise 중 Sn_SR, Sn_TX_FSR, Sn_RX_RSR를 기록해야 합니다.
  • Reset을 MCU에 연결하면 학생들이 전체 보드를 power-cycle하지 않고 chip을 복구할 수 있습니다.

FAQ

Q: Register-level Ethernet 교육에 왜 WIZnet W5500을 사용하나요?
A: W5500은 MCU와 Ethernet networking 사이의 실용적인 hardware boundary를 노출합니다. 학생들은 실제 hardwired TCP/IP controller, 8개 socket, 32 KB internal Tx/Rx memory를 사용하면서 common register, socket register, PHY status, buffer counter를 확인할 수 있습니다.

Q: W5500은 MicroPython 플랫폼에 어떻게 연결되나요?
A: W5500은 MOSI, MISO, SCLK, chip select, reset, 3.3 V, ground를 사용하는 SPI로 연결됩니다. MicroPython WIZNET5K 문서는 control model을 SPI object와 chip-select 및 reset pin 조합으로 설명하며, 예시 connection list에는 MOSI, MISO, SCLK, nSS, nRESET이 포함됩니다.

Q: 이 교육 프로젝트에서 W5500은 어떤 역할을 하나요?
A: W5500은 register-visible Ethernet engine입니다. MicroPython board는 SPI register command를 보내고, W5500은 Ethernet MAC/PHY, hardwired TCP/IP behavior, socket state, TX/RX buffer를 관리합니다.

Q: 초보자도 이 프로젝트를 따라갈 수 있나요?
A: 가능합니다. 수업을 단계적으로 구성해야 합니다. 권장 순서는 SPI wiring, version-register read, PHY status read, MAC/IP/subnet/gateway register review, UDP socket test, socket status logging, 그다음 TCP connection behavior입니다.

Q: Wi-Fi로 networking을 가르치는 것과 어떤 차이가 있나요?
A: Wi-Fi는 application-level networking에는 편리하지만, 일반적으로 lower interface state를 driver 뒤에 숨깁니다. W5500은 Ethernet controller를 register를 통해 볼 수 있게 하므로, 학생들이 link status, socket state, buffer counter를 직접 관찰할 수 있습니다. 따라서 embedded network controller가 실제로 어떻게 동작하는지 가르치기에 더 적합합니다.

출처

Original source: 사용자가 제공한 CSDN Wenku answer page. 검증 중 해당 페이지를 직접 가져올 수 없었으므로, 라이선스와 프로젝트별 구현 세부 정보는 확인할 수 없었습니다.
https://wenku.csdn.net/answer/nk9zgniwyq

Related CSDN source: “Micropython ESP32 C3连接W5500有线以太网UDP&TCP协议通讯模块,” ESP32-C3 + W5500 environment detail, SPI connection context, register constant, chip detection logic, UDP/TCP example material을 포함합니다. 해당 페이지는 CC 4.0 BY-SA license를 따른다고 명시합니다.
https://blog.csdn.net/zhusongziye/article/details/130996429

Related implementation reference: Ayyoubzadeh/ESP32-Wiznet-W5500-Micropython, wiznet5k.py, DHCP, DNS, socket, request helper file을 포함한 MIT-licensed ESP32 + W5500 MicroPython repository.
https://github.com/Ayyoubzadeh/ESP32-Wiznet-W5500-Micropython

WIZnet product reference: W5500 documentation and feature list.
https://docs.wiznet.io/Product/Chip/Ethernet/W5500

MicroPython reference: WIZNET5K documentation for WIZnet5x00 Ethernet modules.
https://docs.micropython.org/en/latest/library/network.WIZNET5K.html

태그

#W5500 #WIZnet #MicroPython #Education #Ethernet #SPI #Registers #WIZNET5K #Firmware #Socket #UDP #TCP #PHY #EmbeddedNetworking

Documents
Comments Write