W5100 UDP Socket Question

#1

I recently started using the w5100 ethernet chip, and the ping the ping test went fine. I am able to set the GWR, SUBR, SHAR, SIPR registers and also read them back just fine (to verify they are being set correctly).

I am also able to open up an UDP socket (I am trying to sent a packet to a NTP server on port 123).

However when I write the SnDIPR and SNPORT for socket 0, when I read the back I get all 0’s.

Reading MR : 0<\r> IP Address : 192.168.0.180<\r> Subnet Mask : 255.255.255.0<\r> Gateway Address : 192.168.0.1<\r> Gateway Address : 48.02.2A.32.00.82<\r> Socket 0 open in UDP @ source port 123<\r> Socket 0 Destination IP: 0.0.0.0<\r> Socket 0 Destination Port : 0.0<\r>

As per the datasheet, under SnDIPR … “In UDP mode, this register value decided to user’s written value after receiving peer’s ARP response. Before receiving peer’s ARP response, this register has reset value.

My code is:

[code]//set destination ntp ip address
val[0]=165; val[1]=193; val[2]=126; val[3]=229;
ETHERNET_WRITE(SOCKET_0_BASE + SNDIPR, val, 4);
retval = ETHERNET_READ(SOCKET_0_BASE + SNDIPR, 4);
printf(“Socket 0 Destination IP: %u.%u.%u.%u\r”,retval[0],retval[1],retval[2],retval[3]);

//set destination port
val[0] = 0x00;
val[1] = 0x7B;
ETHERNET_WRITE(SOCKET_0_BASE + SNDPORT, val, 2);
retval = ETHERNET_READ(SOCKET_0_BASE + SNDPORT, 2);
printf(“Socket 0 Destination Port : %u.%u\r”,retval[0],retval[1]);
[/code]

I feel my issue is something to do with this. What I want to understand is how to open a UDP socket and send data to a server on specified ip/port.

Any help is much appreciated ! :smiley:

#2

Hi,
Beccause UDP socket can support multi-peer communication, Sn_DIPR & Sn_DPORTR can’t represent the peer information. The peer information represen in the received buffer of UDP socket. (refer to datasheet).
That is, Sn_DIPR & Sn_DPORTR could not be regsiter to be verified (write and read value is equal).

We are really sorry for misleading in datasheet as follows.

Thank you.