Wiznet makers

gavinchang

Published July 03, 2026 ©

103 UCC

25 WCC

68 VAR

0 Contests

4 Followers

0 Following

Original Link

How to Teach W5500 Register-Level Ethernet Control with WIZnet W5500 on ESP32?

This article explains an education-oriented WIZnet W5500 Ethernet project with a focus on registers.

COMPONENTS
PROJECT DESCRIPTION

1. Title

How to Teach W5500 Register-Level Ethernet Control with WIZnet W5500 on ESP32?

2. Summary

This article explains an education-oriented WIZnet W5500 Ethernet project with a focus on registers. The target platform is an ESP32-class MicroPython board connected to a W5500 Ethernet module over SPI. The MCU runs the teaching firmware and socket examples, while W5500 provides the Ethernet MAC/PHY, hardwired TCP/IP stack, eight sockets, and internal Tx/Rx buffers. The original CSDN Wenku answer page could not be directly opened during verification, so this article uses accessible related CSDN material, official WIZnet documentation, and official MicroPython WIZNET5K documentation for the register-level explanation.

3. What the Project Does

The related accessible CSDN material describes an ESP32-C3 MicroPython setup connected to a W5500 wired Ethernet UDP/TCP communication module. It shows that the W5500 module is connected through SPI wiring, and it includes a wiznet5k.py driver section with W5500 register constants, socket status constants, socket command constants, and PHY/link helper logic. The page is marked as CC 4.0 BY-SA and is used here as a related reference pattern, not as proof of the inaccessible Wenku page.

For an education use case, the project is useful because students can see that Ethernet communication is not only a black-box socket.send() call. The W5500 exposes a register model behind the driver. Common registers describe the chip mode, gateway address, subnet mask, MAC address, source IP address, PHY configuration, socket mode, socket command, socket status, destination IP, destination port, TX free size, RX received size, and buffer pointers.

The teaching data flow can be explained in layers:

ESP32 MicroPython code → WIZNET5K driver → SPI register read/write → W5500 common/socket registers → W5500 TCP/IP engine → Ethernet network.

In the reverse direction:

Ethernet packet → W5500 RX buffer → socket received-size register → driver read path → MicroPython socket API → student application code.

This makes the project suitable for teaching embedded networking, because students can connect high-level socket behavior to concrete register-level state.

4. Where WIZnet Fits

The WIZnet product in this architecture is W5500. WIZnet describes W5500 as a hardwired TCP/IP stack Internet controller that connects to an external MCU through SPI up to 80 MHz. It integrates a 10/100 Ethernet MAC and PHY, supports TCP, UDP, ICMP, IPv4, ARP, IGMP, and PPPoE, provides eight independent sockets, and includes 32 KB internal memory for Tx/Rx buffers.

At the register level, W5500 is the hardware network engine that MicroPython controls through SPI. The MCU writes network identity registers such as gateway, subnet, MAC address, and source IP. It also reads PHY and socket status registers to understand whether the cable is linked, whether a TCP socket is listening, established, closed, or waiting, and whether there is data to receive.

This is valuable for education because it gives students a concrete bridge between three views of the same system:

Network view: IP address, gateway, subnet, port, TCP/UDP socket.

Driver view: WIZNET5K, socket API, send/receive functions, link status checks.

Register view: common registers, socket registers, command registers, status registers, and buffer pointers.

W5500’s practical limits are also visible at the register level. It supports eight sockets, uses internal Tx/Rx buffer memory, supports SPI Mode 0 and Mode 3, and does not support IP fragmentation. These constraints should be explained as part of the lesson, not hidden behind the driver.

5. Implementation Notes

Because the exact Wenku page could not be directly verified, this section does not claim hidden file paths or project-specific snippets from that page. Instead, it uses a visible related CSDN driver pattern and official documentation.

The related CSDN MicroPython W5500 driver section exposes useful register constants:

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_SNIR = const(0x0002)        # Socket n Interrupt
REG_SNSR = const(0x0003)        # Socket n Status
REG_SNPORT = const(0x0004)      # Socket n Source Port
REG_SNDIPR = const(0x000C)      # Destination IP Address
REG_SNDPORT = const(0x0010)     # Destination Port
REG_SNTX_FSR = const(0x0020)    # Socket n TX Free Size
REG_SNTX_WR = const(0x0024)     # TX Write Pointer
REG_SNRX_RSR = const(0x0026)    # RX Received Size
REG_SNRX_RD = const(0x0028)     # RX Read Pointer

This snippet is useful because it turns W5500 networking into a register map that students can inspect. REG_GAR, REG_SUBR, REG_SHAR, and REG_SIPR describe the network identity of the device. REG_PHYCFGR shows PHY/link information. REG_SNMR, REG_SNCR, REG_SNIR, and REG_SNSR describe socket mode, command, interrupt, and status. REG_SNTX_FSR, REG_SNTX_WR, REG_SNRX_RSR, and REG_SNRX_RD connect socket behavior to buffer management.

The same visible driver section shows socket status and command constants:

SNSR_SOCK_CLOSED = const(0x00)
SNSR_SOCK_INIT = const(0x13)
SNSR_SOCK_LISTEN = const(0x14)
SNSR_SOCK_ESTABLISHED = const(0x17)
SNSR_SOCK_CLOSE_WAIT = const(0x1C)
SNSR_SOCK_UDP = const(0x22)

CMD_SOCK_OPEN = const(0x01)
CMD_SOCK_LISTEN = const(0x02)
CMD_SOCK_CONNECT = const(0x04)
CMD_SOCK_DISCON = const(0x08)
CMD_SOCK_CLOSE = const(0x10)
CMD_SOCK_SEND = const(0x20)
CMD_SOCK_RECV = const(0x40)

For a classroom exercise, these constants can be used to draw a socket state diagram. For example, students can observe a TCP server moving from CLOSED to INIT, then LISTEN, then ESTABLISHED, and finally CLOSE_WAIT or CLOSED. They can also connect commands such as OPEN, LISTEN, SEND, RECV, and CLOSE to the socket register writes that drive W5500 behavior.

Official MicroPython documentation also supports register-level debugging. The WIZNET5K class is constructed with an SPI object, chip-select pin, and reset pin, and the module requires MOSI, MISO, SCLK, nSS, and nRESET connections. The documentation also includes WIZNET5K.regs(), which dumps WIZnet5x00 registers for debugging.

6. Practical Tips / Pitfalls

Start with chip detection. Read REG_VERSIONR_W5500 and confirm the expected W5500 version value before teaching sockets. If the chip cannot be detected, socket debugging is meaningless.

Separate common registers from socket registers. Common registers describe the device network identity and PHY state. Socket registers describe one communication channel. This separation helps students avoid confusing IP setup with TCP state.

Use REG_PHYCFGR early. Link status, speed, and duplex behavior are easier to debug when students can inspect PHY configuration instead of guessing whether the cable or router is the problem.

Teach socket state as a finite-state machine. Registers such as REG_SNSR make TCP behavior visible. This is useful for explaining why a server must listen before it can accept traffic.

Connect TX/RX registers to buffers. REG_SNTX_FSR, REG_SNTX_WR, REG_SNRX_RSR, and REG_SNRX_RD show that send and receive operations depend on buffer availability and pointer updates.

Use small packets first. W5500 has 32 KB internal Tx/Rx memory, but classroom examples are easier to debug with short UDP messages or simple TCP echo frames.

Keep register dumps readable. Do not print every register in every loop. Dump registers at startup, on link change, on socket state change, and after an error.

7. FAQ

Why use WIZnet W5500 for this project?
W5500 is useful for register-level education because it exposes a concrete hardware networking model while still providing a hardwired TCP/IP stack. Students can study gateway, subnet, MAC, IP, PHY, socket status, socket command, and buffer registers without implementing a full TCP/IP stack from scratch. W5500 also provides eight sockets and 32 KB internal Tx/Rx buffer memory, making the socket model practical for lab work.

How does W5500 connect to the platform?
In MicroPython, W5500 is controlled through the WIZNET5K driver using SPI, chip select, and reset. The official MicroPython documentation lists MOSI, MISO, SCLK, nSS, and nRESET as the required module connections and states that other SPI buses and pins can be used depending on the board.

What role does W5500 play in this project?
W5500 is the register-controlled Ethernet and TCP/IP engine. ESP32 runs the teaching firmware and student application, while W5500 handles Ethernet MAC/PHY behavior, hardwired TCP/IP protocols, socket state, and packet buffering.

Can beginners follow this project?
Yes. Beginners should start with physical wiring, chip detection, MAC/IP register setup, PHY link status, and one UDP or TCP socket. After that, they can move into socket status, socket commands, TX/RX buffer registers, and register dumps.

Why focus on registers for education?
Registers reveal what the driver is doing. A normal socket example may hide the network state, but a register-focused lesson shows how IP configuration, PHY link, socket state, send/receive buffers, and error recovery are represented in hardware.

8. Source

Original CSDN Wenku answer page:
https://wenku.csdn.net/answer/1ay71zwgz9
The page returned an internal error during browsing, so this article does not claim project-specific code, wiring, or register explanations from that exact Wenku page.

Accessible related CSDN reference:
“物联网开发117 - Micropython ESP32 C3连接W5500有线以太网UDP&TCP协议通讯模块,” which includes ESP32-C3 + W5500 MicroPython context, SPI connection notes, W5500 driver constants, socket status constants, socket command constants, and PHY/link helper logic. The page displays a CC 4.0 BY-SA copyright notice.

Official WIZnet W5500 documentation:
Used for W5500 hardwired TCP/IP stack, SPI up to 80 MHz, 10/100 Ethernet MAC/PHY, supported protocols, eight sockets, 32 KB internal Tx/Rx buffer memory, SPI Mode 0/3 support, and IP-fragmentation limitation.

Official MicroPython WIZNET5K documentation:
Used for WIZNET5K constructor behavior, SPI/CS/reset wiring model, socket usage pattern, and regs() register dump method.

Editorial workflow and source-handling rules followed the uploaded WIZnet UCC Curator Handover Notes.

9. Tags

WIZnet, W5500, ESP32, MicroPython, Registers, Ethernet, TCP/IP, SPI, Socket Status, PHY Configuration, Education, Embedded Networking

 

1. 제목

ESP32에서 WIZnet W5500을 사용해 W5500 Register-Level Ethernet Control을 교육하는 방법

2. 요약

이 글은 register에 초점을 둔 education-oriented WIZnet W5500 Ethernet project를 설명한다. 대상 platform은 SPI를 통해 W5500 Ethernet module에 연결된 ESP32 계열 MicroPython board이다. MCU는 teaching firmware와 socket example을 실행하고, W5500은 Ethernet MAC/PHY, hardwired TCP/IP stack, 8개의 socket, internal Tx/Rx buffer를 제공한다. 원본 CSDN Wenku answer page는 검증 중 직접 열 수 없었으므로, 이 글은 접근 가능한 관련 CSDN 자료, 공식 WIZnet documentation, 공식 MicroPython WIZNET5K documentation을 사용해 register-level 설명을 구성한다.

3. 프로젝트가 하는 일

접근 가능한 관련 CSDN 자료는 ESP32-C3 MicroPython setup이 W5500 wired Ethernet UDP/TCP communication module에 연결되는 구성을 설명한다. W5500 module은 SPI wiring을 통해 연결되며, wiznet5k.py driver section에는 W5500 register constant, socket status constant, socket command constant, PHY/link helper logic이 포함되어 있다. 해당 page는 CC 4.0 BY-SA로 표시되어 있으며, 여기서는 접근 불가능한 Wenku page의 증거가 아니라 관련 reference pattern으로 사용한다.

Education use case에서 이 project는 Ethernet communication이 단순한 black-box socket.send() 호출만이 아니라는 점을 보여주기 때문에 유용하다. W5500은 driver 뒤에 register model을 제공한다. 일반적인 register는 chip mode, gateway address, subnet mask, MAC address, source IP address, PHY configuration, socket mode, socket command, socket status, destination IP, destination port, TX free size, RX received size, buffer pointer를 설명한다.

Teaching data flow는 layer별로 다음과 같이 설명할 수 있다.

ESP32 MicroPython code → WIZNET5K driver → SPI register read/write → W5500 common/socket registers → W5500 TCP/IP engine → Ethernet network.

반대 방향은 다음과 같다.

Ethernet packet → W5500 RX buffer → socket received-size register → driver read path → MicroPython socket API → student application code.

이 구조는 high-level socket behavior를 구체적인 register-level state와 연결할 수 있기 때문에 embedded networking 교육에 적합하다.

4. WIZnet이 들어가는 위치

이 architecture에서 사용하는 WIZnet 제품은 W5500이다. WIZnet은 W5500을 외부 MCU와 최대 80 MHz SPI로 연결되는 hardwired TCP/IP stack Internet controller로 설명한다. W5500은 10/100 Ethernet MAC과 PHY를 통합하고, TCP, UDP, ICMP, IPv4, ARP, IGMP, PPPoE를 지원하며, 8개의 independent socket과 Tx/Rx buffer용 32 KB internal memory를 제공한다.

Register level에서 W5500은 MicroPython이 SPI를 통해 제어하는 hardware network engine이다. MCU는 gateway, subnet, MAC address, source IP 같은 network identity register를 기록한다. 또한 PHY와 socket status register를 읽어 cable link 여부, TCP socket이 listening, established, closed, waiting 상태인지, 수신할 data가 있는지를 확인한다.

이는 education에서 유용하다. 학생들이 동일한 system을 세 가지 관점으로 볼 수 있기 때문이다.

Network view: IP address, gateway, subnet, port, TCP/UDP socket.

Driver view: WIZNET5K, socket API, send/receive function, link status check.

Register view: common register, socket register, command register, status register, buffer pointer.

W5500의 practical limit도 register level에서 확인할 수 있다. W5500은 8개의 socket을 지원하고, internal Tx/Rx buffer memory를 사용하며, SPI Mode 0과 Mode 3을 지원하고, IP fragmentation은 지원하지 않는다. 이러한 constraint는 driver 뒤에 숨기지 말고 lesson의 일부로 설명하는 것이 좋다.

5. 구현 참고 사항

정확한 Wenku page를 직접 검증할 수 없었기 때문에, 이 section은 해당 page의 hidden file path나 project-specific snippet을 주장하지 않는다. 대신 visible related CSDN driver pattern과 공식 documentation을 사용한다.

관련 CSDN MicroPython W5500 driver section은 유용한 register constant를 보여준다.

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_SNIR = const(0x0002)        # Socket n Interrupt
REG_SNSR = const(0x0003)        # Socket n Status
REG_SNPORT = const(0x0004)      # Socket n Source Port
REG_SNDIPR = const(0x000C)      # Destination IP Address
REG_SNDPORT = const(0x0010)     # Destination Port
REG_SNTX_FSR = const(0x0020)    # Socket n TX Free Size
REG_SNTX_WR = const(0x0024)     # TX Write Pointer
REG_SNRX_RSR = const(0x0026)    # RX Received Size
REG_SNRX_RD = const(0x0028)     # RX Read Pointer

이 snippet은 W5500 networking을 학생들이 inspect할 수 있는 register map으로 바꿔주기 때문에 유용하다. REG_GAR, REG_SUBR, REG_SHAR, REG_SIPR은 device의 network identity를 설명한다. REG_PHYCFGR은 PHY/link information을 보여준다. REG_SNMR, REG_SNCR, REG_SNIR, REG_SNSR은 socket mode, command, interrupt, status를 설명한다. REG_SNTX_FSR, REG_SNTX_WR, REG_SNRX_RSR, REG_SNRX_RD는 socket behavior를 buffer management와 연결한다.

같은 visible driver section은 socket status와 command constant도 보여준다.

SNSR_SOCK_CLOSED = const(0x00)
SNSR_SOCK_INIT = const(0x13)
SNSR_SOCK_LISTEN = const(0x14)
SNSR_SOCK_ESTABLISHED = const(0x17)
SNSR_SOCK_CLOSE_WAIT = const(0x1C)
SNSR_SOCK_UDP = const(0x22)

CMD_SOCK_OPEN = const(0x01)
CMD_SOCK_LISTEN = const(0x02)
CMD_SOCK_CONNECT = const(0x04)
CMD_SOCK_DISCON = const(0x08)
CMD_SOCK_CLOSE = const(0x10)
CMD_SOCK_SEND = const(0x20)
CMD_SOCK_RECV = const(0x40)

Classroom exercise에서는 이러한 constant를 사용해 socket state diagram을 그릴 수 있다. 예를 들어 학생들은 TCP server가 CLOSED에서 INIT, LISTEN, ESTABLISHED로 이동하고, 마지막에 CLOSE_WAIT 또는 CLOSED로 돌아가는 흐름을 관찰할 수 있다. 또한 OPEN, LISTEN, SEND, RECV, CLOSE 같은 command를 W5500 동작을 유도하는 socket register write와 연결할 수 있다.

공식 MicroPython documentation도 register-level debugging을 지원한다. WIZNET5K class는 SPI object, chip-select pin, reset pin으로 생성되며, module에는 MOSI, MISO, SCLK, nSS, nRESET connection이 필요하다. Documentation에는 debugging용으로 WIZnet5x00 register를 dump하는 WIZNET5K.regs()도 포함되어 있다.

6. 실용 팁 / 주의점

Chip detection부터 시작한다. Socket을 가르치기 전에 REG_VERSIONR_W5500을 읽어 예상 W5500 version value를 확인한다. Chip이 감지되지 않으면 socket debugging은 의미가 없다.

Common register와 socket register를 분리한다. Common register는 device network identity와 PHY state를 설명한다. Socket register는 하나의 communication channel을 설명한다. 이 구분은 학생들이 IP setup과 TCP state를 혼동하지 않도록 돕는다.

REG_PHYCFGR을 초기에 사용한다. Link status, speed, duplex behavior는 cable이나 router 문제를 추측하는 것보다 PHY configuration을 inspect할 때 훨씬 쉽게 debug할 수 있다.

Socket state를 finite-state machine으로 가르친다. REG_SNSR 같은 register는 TCP behavior를 보이게 만든다. 이는 server가 traffic을 받기 전에 왜 listen 상태가 되어야 하는지 설명하는 데 유용하다.

TX/RX register를 buffer와 연결한다. REG_SNTX_FSR, REG_SNTX_WR, REG_SNRX_RSR, REG_SNRX_RD는 send/receive operation이 buffer availability와 pointer update에 의존한다는 점을 보여준다.

Small packet부터 사용한다. W5500은 32 KB internal Tx/Rx memory를 제공하지만, classroom example은 짧은 UDP message나 simple TCP echo frame으로 debug하는 것이 더 쉽다.

Register dump는 읽기 쉽게 유지한다. Loop마다 모든 register를 print하지 않는다. Startup, link change, socket state change, error 이후에 register를 dump하는 것이 좋다.

7. FAQ

왜 이 프로젝트에 WIZnet W5500을 사용하나?
W5500은 hardwired TCP/IP stack을 제공하면서도 구체적인 hardware networking model을 보여주기 때문에 register-level education에 유용하다. 학생들은 완전한 TCP/IP stack을 처음부터 구현하지 않고도 gateway, subnet, MAC, IP, PHY, socket status, socket command, buffer register를 학습할 수 있다. 또한 W5500은 8개의 socket과 32 KB internal Tx/Rx buffer memory를 제공하므로 socket model을 lab work에 실용적으로 사용할 수 있다.

W5500은 platform과 어떻게 연결되나?
MicroPython에서 W5500은 SPI, chip select, reset을 사용하는 WIZNET5K driver를 통해 제어된다. 공식 MicroPython documentation은 필요한 module connection으로 MOSI, MISO, SCLK, nSS, nRESET을 나열하며, board에 따라 다른 SPI bus와 pin을 사용할 수 있다고 설명한다.

이 프로젝트에서 W5500의 역할은 무엇인가?
W5500은 register-controlled Ethernet 및 TCP/IP engine이다. ESP32는 teaching firmware와 student application을 실행하고, W5500은 Ethernet MAC/PHY behavior, hardwired TCP/IP protocols, socket state, packet buffering을 처리한다.

초보자도 이 project를 따라 할 수 있나?
가능하다. 초보자는 physical wiring, chip detection, MAC/IP register setup, PHY link status, 하나의 UDP 또는 TCP socket부터 시작하는 것이 좋다. 이후 socket status, socket command, TX/RX buffer register, register dump로 확장할 수 있다.

왜 education에서 register에 초점을 두나?
Register는 driver가 실제로 무엇을 하고 있는지 보여준다. 일반적인 socket example은 network state를 숨길 수 있지만, register-focused lesson은 IP configuration, PHY link, socket state, send/receive buffer, error recovery가 hardware에서 어떻게 표현되는지 보여준다.

8. 출처

Original CSDN Wenku answer page:
https://wenku.csdn.net/answer/1ay71zwgz9
해당 page는 browsing 중 internal error를 반환했으므로, 이 글은 그 정확한 Wenku page의 project-specific code, wiring, register explanation을 주장하지 않는다.

Accessible related CSDN reference:
“物联网开发117 - Micropython ESP32 C3连接W5500有线以太网UDP&TCP协议通讯模块”은 ESP32-C3 + W5500 MicroPython context, SPI connection note, W5500 driver constant, socket status constant, socket command constant, PHY/link helper logic을 포함한다. 해당 page에는 CC 4.0 BY-SA copyright notice가 표시되어 있다.

Official WIZnet W5500 documentation:
W5500 hardwired TCP/IP stack, 최대 80 MHz SPI, 10/100 Ethernet MAC/PHY, supported protocols, 8 sockets, 32 KB internal Tx/Rx buffer memory, SPI Mode 0/3 support, IP-fragmentation limitation 확인에 사용했다.

Official MicroPython WIZNET5K documentation:
WIZNET5K constructor behavior, SPI/CS/reset wiring model, socket usage pattern, regs() register dump method 확인에 사용했다.

Editorial workflow와 source-handling rule은 업로드된 WIZnet UCC Curator Handover Notes를 따랐다.

9. 태그

WIZnet, W5500, ESP32, MicroPython, Registers, Ethernet, TCP/IP, SPI, Socket Status, PHY Configuration, Education, Embedded Networking

Documents
Comments Write