---
title: "W5500 hangs when creating the socket"
url: "https://maker.wiznet.io/forum/11626"
markdown_url: "https://maker.wiznet.io/forum/11626/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "temonsx"
created: "2016-01-27T03:57:28+09:00"
last_activity: "2017-05-04T08:38:07+09:00"
language: "en"
views: 954
replies: 1
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# W5500 hangs when creating the socket

## Question

Asked by temonsx on 2016-01-27 in Ethernet Chips.

Hello! ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12)
I am using STM32F4 and W5500. I connected to the ioLibrary project. SPI it works fine.
ctlnetwork(CN_SET_NETINFO, (void*)&gWIZNETINFO);
ctlnetwork(CN_GET_NETINFO, (void*)&test);
Network parameters successfully installed and W5500 pinged lossless.
Creates a socket, but when debugging function freezes… ![:open_mouth:](https://emoji.discourse-cdn.com/twitter/open_mouth.png?v=12)
socket(0, Sn_MR_TCP, 1005, 0);
It hangs on the function close() at line: while( getSn_CR(sn) );
Please tell me what could be the reason? ![:neutral_face:](https://emoji.discourse-cdn.com/twitter/neutral_face.png?v=12)
Forgive me for my english, I’m from Russia ![:slight_smile:](https://emoji.discourse-cdn.com/twitter/slight_smile.png?v=12)

## Replies

### Reply 1 by temonsx, 2016-01-27

I figured, just in write_spi(uint8_t wr_byte); needed to add a function read to read the first byte read differently corresponded previously accepted values.
void write_spi(uint8_t wr_byte)
{
SPI_I2S_SendData(SPI1, wr_byte);
while(SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_BSY) == SET);
SPI_I2S_ReceiveData(SPI1); /* that’s what was missing */
}
Everything is working. ![:smiley:](https://emoji.discourse-cdn.com/twitter/smiley.png?v=12)

---

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