Datasheet

46 / 66 W5500 Datasheet Version1.0.9
Sn_CR (Socket n Command Register) [R/W] [0x0001] [0x00]
This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN,
SEND, and RECEIVE. After W5500 accepts 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. To check whether the command is completed or not, please
check the Sn_IR or Sn_SR.
Value
Symbol
Description
0x01
OPEN
Socket n is initialized and opened according to the protocol selected
in Sn_MR (P3:P0). The table below shows the value of Sn_SR
corresponding to Sn_MR.
Sn_MR (P[3:0])
Sn_SR
Sn_MR_CLOSE (0000)
-
Sn_MR_TCP (0001)
SOCK_INIT (0x13)
Sn_MR_UDP (0010)
SOCK_UDP (0x22)
S0_MR_MACRAW (0100)
SOCK_MACRAW (0x42)
.
0x02
LISTEN
This is valid only in TCP mode (Sn_MR(P3:P0) = Sn_MR_TCP). In this
mode, Socket n operates as a ‘TCP server’ and waits for connection-
request (SYN packet) from any ‘TCP client’.
The Sn_SR changes the state from SOCK_INIT to SOCKET_LISTEN.
When a ‘TCP client’ connection request is successfully established,
the Sn_SR changes from SOCK_LISTEN to SOCK_ESTABLISHED and the
Sn_IR(0) becomes 1. But when a ‘TCP client’ connection request is
failed, Sn_IR(3) becomes 1 and the status of Sn_SR changes to
SOCK_CLOSED.
0x04
CONNECT
This is valid only in TCP mode and operates when Socket n acts as
‘TCP client’. To connect, a connect-request (SYN packet) is sent to
‘TCP server’ configured by Sn_DIPR & Sn_DPORT(destination address
& port). If the connect-request is successful, the Sn_SR is changed to
SOCK_ESTABLISHED and the Sn_IR(0) becomes ‘1’.
The connect-request fails in the following three cases.
1. When a ARP
TO
occurs (Sn_IR(3)=‘1’) because the destination
hardware address is not acquired through the ARP-process.
2. When a SYN/ACK packet is not received and TCP
TO
(Sn_IR(3) =
‘1 )
3. When a RST packet is received instead of a SYN/ACK packet.