Data Sheet
© Copyright 2013 WIZnet Co.,Ltd. All rights reserved.
26
iEthernet
W5200
Sn_CR (Socket n Command Register) [R/W] [0x4001+0x0n00] [0x00]
This is used to set the command for Socket n such as OPEN, CLOSE, CONNECT, LISTEN, SEND,
and RECEIVE. 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.
To verify whether the command is completed or not, please check the Sn_IR or Sn_SR
registers.
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(P3:P0) Sn_SR
Sn_MR_CLOSE (0x00) -
Sn_MR_TCP (0x01) SOCK_INIT (0x13)
Sn_MR_UDP (0x02) SOCK_UDP (0x22)
Sn_MR_IPRAW (0x03) SOCK_IPRAW (0x32)
S0_MR_MACRAW (0x04) SOCK_MACRAW (0x42)
S0_MR_PPPoE (0x05) SOCK_PPPoE (0x5F)
0x02
LISTEN
This is valid only in TCP mode (Sn_MR(P3:P0) = Sn_MR_TCP). In this
mode, the Socket n is configured as a TCP server which is waiting for
connection-request (SYN packet) from any “TCP CLIENT”. The Sn_SR
register changes the state from SOCK_INIT to SOCKET_LISTEN.
When a client’s connection request is successfully established, the Sn_SR
changes from SOCK_LISTEN to SOCK_ESTABLISHED and the Sn_IR(0)
becomes ‘1’. On the other hand, Sn_IR(3) is set as ‘1’ and Sn_SR changes
to SOCK_CLOSED during a connection failure(SYN/ACK packet failed to
transfer)
cf> If the destination port of the TCP Client does not exist during a
connection request, W5200 will transmit a RST packet and Sn_SR is
unchanged.
0x04
CONNECT
This mode is only valid in TCP mode and operates the Socket n as a TCP
client.A connect-request (SYN packet) is sent to the TCP server by
connecting to the IP address and port stored in destination address and
port registers (Sn_DIPR0 and Sn_DPORT0)
When a client’s connection request is successfully established, the Sn_SR
register is changed to SOCK_ESTABLISHED and the Sn_IR(0) becomes
‘1’.In the following cases, the connect-request fails When a ARPTO
occurs (Sn_IR(s)=‘1’) because the Destination Hardware Address is not
acquired through the ARP process
When a SYN/ACK packet is not received and TCPTO(Sn_IR(3)) is’1’