---
title: "W5200 Sn_CR(0) register is not clearing automatically"
url: "https://maker.wiznet.io/forum/9701"
markdown_url: "https://maker.wiznet.io/forum/9701/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "selaslan"
created: "2013-11-25T16:42:36+09:00"
last_activity: "2017-05-04T08:30:31+09:00"
language: "en"
views: 529
replies: 1
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# W5200 Sn_CR(0) register is not clearing automatically

## Question

Asked by selaslan on 2013-11-25 in Ethernet Chips.

Hi

I’m using W5200 and your driver V1.5 with my STM32F103 board.

I have written the initial registers such (GAR, SUBR SIPR etc)
all are ok.

But When I try to initiate sockets by sending following fucntion
socket(s, Sn_MR_TCP , S0_SourcePort, 0)

The w5200 chip starts endless loop

I have debugged in detail. The cpu is going to endless loop in close(s) command
The cpu sends Sn_CR_CLOSE command. But the chip is not operating.
Sn_CR(0) register content is always 0xFF after sending the close command.
It should be cleared to 0x00 automatically

---

*/
void close(SOCKET s)
{
#ifdef **DEF_IINCHIP_DBG**
printf(“close()\r\n”);
#endif

```
IINCHIP_WRITE(Sn_CR(s),Sn_CR_CLOSE);

/* wait to process the command... */
while( IINCHIP_READ(Sn_CR(s)) ) 
	;
/* ------- */
            /* all clear */
	IINCHIP_WRITE(Sn_IR(s), 0xFF);
```

}

---

Rgds

## Replies

### Reply 1 by irinakim, 2013-11-26

Hi, Selaslan

You’re right. After W5200 identifies the command, the Sn_CR register is automatically cleared to 0x00.
Even though Sn_CR is cleared to 0x00, the command is still being processed.
Therefore, you have to check the Sn_IR or Sn_SR registers.

I could not understand.
You says “Sn_CR(0) register content is always 0xFF after sending the close command.”
Sn_CR don’t have 0xFF. If you read the Sn_IR after Sn_CR command excute, It has 0xFF.

Please you have to check the Sn_IR or Sn_SR registers.

Best regards,
Irian Kim ![:smiley:](https://emoji.discourse-cdn.com/twitter/smiley.png?v=12)

---

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