---
title: "W5500, SPI ok, Sn_SR always 0x00, TCP"
url: "https://maker.wiznet.io/forum/10621"
markdown_url: "https://maker.wiznet.io/forum/10621/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "aomgemalmaz"
created: "2014-10-24T09:48:19+09:00"
last_activity: "2018-12-10T09:09:41+09:00"
language: "en"
views: 1761
replies: 8
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# W5500, SPI ok, Sn_SR always 0x00, TCP

## Question

Asked by aomgemalmaz on 2014-10-24 in Ethernet Chips.

hello,

I have completely activate the SPI communication. I can read and write data to W5500 chip. I checked from scope and from keil.
I am going to use this chip for tcp communication. My master is a Freescale KL25 MCU and w5500 is my slave.

I have found the tcp guide for w5500.

For now I am just using socket 0.

I have written the gateway, source IP and read them. They are ok.I can read them.

then for tcp:

1- I adjusted the mode register for TCP usage.( 0x01) (I read this value correctly)
2-I adjusted port adress as 31000 (I read this value correctly)
3- Command register, SN_CR= 0x01 (Open the port)
the problem starts here. I should read 0x13(SOCK_INIT) from the status register. However I cannot read that value.

Then I will have w5500 to go listen mode.

Could you please help me what should I do. Is there anything I should do write or check ?

Thank you

## Replies

### Reply 1 by hjjeon0608, 2014-10-27

Did you wait command register is cleared??

Plz, check this out.

### Reply 2 by aomgemalmaz, 2014-10-28

[quote=“hjjeon0608”]Did you wait command register is cleared??

Plz, check this out.[/quote]

I have seen that the Sn_CR is cleared after Open command.

However still I can not see SOCK_INIT status.

### Reply 3 by aomgemalmaz, 2014-10-28

[quote=“midnightcow”]Hi,

You will check the control byte of SPI frame.

I think that the control byte maybe wrong and you did accesse the other device as memory, instead of W5500.

As you mentioned before,
If the socket registers as Sn_MR, Sn_SPORT is normally write & read, OPEN command in Sn_CR regsiter will change the Sn_CR from SOCK_CLOSED to SOCK_INIT.

Plz, Verify block selected bits in the control byte.

Thank you.[/quote]

I have already checked these BSBs. I think there is no problem of SPI frame. Because I can read and write.
For example RTR(retry time register) has default of “0x07D0” which I can read and write via SPI.

### Reply 4 by aomgemalmaz, 2014-11-06

I have solved the problem. The problem was related with my spi_send function.
I arranged again and with the correct addres values.
Thanks for all replies.

### Reply 5 by hjjeon0608, 2014-11-07

I’m glad to hear you solved problem. ![:smiley:](https://emoji.discourse-cdn.com/twitter/smiley.png?v=12)

### Reply 6 by mrprice, 2014-11-19

Hi,
I’m facing the exact same problem.
Can you elaborate how did you solve it?
what was the problem with the send function?

thanks
Price

### Reply 7 by Alka Yadav, 2018-12-10

hi,
my Sn_SR register value always set 0x00, its not change its value from 0x00 to 0x22.
my code:
START:
setMR(Sn_MR_UDP);
setSn_PORT(0, 11000);
setSn_CR(0, Sn_CR_OPEN);
if(getSn_SR(0) !=SOCK_UDP)
{
setSn_CR(0, Sn_CR_CLOSE);
goto START;
}

### Reply 8 by Eugeny, 2018-12-10 (in reply to reply 7)

![](https://avatars.discourse-cdn.com/v4/letter/a/67e7ee/48.png) Alka_Yadav:

> ```
setMR(Sn_MR_UDP);
```

You must set socket’s MR to this value, not common register block’s MR.

---

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