---
title: "W5500 - can't open socket"
url: "https://maker.wiznet.io/forum/15117"
markdown_url: "https://maker.wiznet.io/forum/15117/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "NeoProg"
created: "2024-01-12T18:34:16+09:00"
last_activity: "2024-01-13T13:55:37+09:00"
language: "en"
views: 173
replies: 4
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# W5500 - can't open socket

## Question

Asked by NeoProg on 2024-01-12 in Ethernet Chips.

Hi everyone, me need help. I trying write DHCP client for gathering IP address but i can’t open socket in UDP mode (as in any other mode). My steps (between steps has delay ~300ms):

- Connect Ethernet cable and power up;

- Hardware reset using RST pin – OK;

- Read Chip ID register and check value (0x04) – OK;

- Software reset by write value 0x80 to Mode Register – OK;

- Wait until RST bit is reset – OK;

- Check PHYCFGR register value - get 0xBF, link UP – OK (may be);

- Write 0x0044 value to S0_PORT register – OK;

- Read value from S0_PORT register and compare with written value (0x0044) – OK;

- Write 0x02 value to S0_MR for UDP mode – OK;

- Read value from S0_MR register and compare with written value (0x02) – OK;

- Write 0x01 value to S0_CR for open socket – OK;

- Read value from S0_CR register and compare with 0x00 (command accepted) – OK;

- Read value from S0_SR – always read 0x00. Why?

I tried this steps for all sockets – can’t open no one. I write to registers using 1MHz SPI speed in SPI_MODE0 (MSB first) and Variable Length Data Mode. I tried using Fixed Lingth Data Mode – without changes. I don’t use some library – only direct write to registers using simple SPI driver.

Also i tried setup static IP address (gateway, mask, source IP) and using ping tool for check W5500 working. W5500 answer on ping requests.

Also i noticed strange behavior with RST bit in PHYCFGR register. After write RST bit to 0 it is not never set to 1, LEDs on Ethernet connector is disabled. After write RST bit to 1 using SPI – LEDs on Ethernet connector is blinks. It is nornaly?

Please, help me. I don’t have no idia :(. I have two W5500 and both don’t work.

## Replies

### Reply 1 by Eugeny, 2024-01-12

NeoProg:

> - Read Chip ID register and check value (0x04) – OK;
>
> - Software reset by write value 0x80 to Mode Register – OK;
>
> - Wait until RST bit is reset – OK;

Would it be better to perform software reset and only then try reading the chip ID? I do not think it is much difference, but I would prefer this way.

NeoProg:

> Read value from S0_SR – always read 0x00. Why?

Good question. Did you set up source MAC address, proper source IP address and mask? Anything in gateway address?

NeoProg:

> After write RST bit to 0 it is not never set to 1

Datasheet does not say it will return back to 1 automatically. It says this bit must be set to 1 after setting it to 0 (for proper PHY operation).

### Reply 2 by NeoProg, 2024-01-12 (in reply to reply 1)

Thanks for your reply!

> Good question. Did you set up source MAC address, proper source IP address and mask? Anything in gateway address?

Yes, i tried open socket after setup in src IP, mask, gateway and mac address correct values. Ping tool is working and W5500 asnwer on ping requests but socket doesn’t open. I try again and return with results.

I want to get IP & mask using DHCP. W5500 does not working with default src IP, mask, gateway (0x0000)?

### Reply 3 by Eugeny, 2024-01-13

Sounds like workflow problem. And you are right, MAC address must be sufficient.
Can you please set port number after setting Sn_MR to 2?

### Reply 4 by NeoProg, 2024-01-13

Sorry, problem was in broken wires for demo board power supply. After resplace wires W5500 work correctly and i can open socket! I should have checked power using oscilloscope before search problem in code. I did school mistake again ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12)

Thanks for help, Eugeny. Have a nice day.

---

Source: https://maker.wiznet.io/forum/15117
