---
title: "Send UDP packet from w5500 to PC failed!"
url: "https://maker.wiznet.io/forum/10139"
markdown_url: "https://maker.wiznet.io/forum/10139/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "yaoliang0270"
created: "2014-04-16T07:26:57+09:00"
last_activity: "2019-05-30T23:22:59+09:00"
language: "en"
views: 1430
replies: 13
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Send UDP packet from w5500 to PC failed!

## Question

Asked by yaoliang0270 on 2014-04-16 in Ethernet Chips.

According below steps, i can’t send an UDP packet.

1. Initialized W5500(set w5500 ip,port, host PC ip, port).

2. Open w5500 upd socket.

3. sendto() packet to host pc.
   the result :failed send out the packet. the register value of IINCHIP_READ( Sn_IR(s)) is timeout all the time.

until I received a packet from PC host using receivefrom(), w5500 can send udp packet to host pc using Sendto() successfully.

PC firewall is disable. antivirus software is closed.

Has anyone meet this issue?

Thanks.

## Replies

### Reply 1 by yaoliang0270, 2014-05-05

Hi midnightcow,

Thanks your reply.

I checked my network config parameters, maybe my host ip and port info error.

Now my prototype can work normal.

Thanks & Best regards,
Ken

### Reply 2 by Maksim, 2019-05-28

I decided not to create a new topic but unsubscribe here,
I have exactly the same problem. Only this happens on power up. order of action such:

1. pull the hardware reset (switch reset)

2. Set soft reset

3. RTR = 1000

4. RCR = 10

5. setSHAR

6. setGAR

7. setSUBR

8. setSIPR
   socket (2, Sn_MR_UDP, 161, 0x00); // ----------- &lt;brekpoint
   if (WIZCHIP_READ (Sn_SR (2)) == 0x22) {
   sendto (2, buff, 10, IP2, 161);
   }
   while (1) {}

If you install breckpins on the socket, the packet is sent, otherwise the wireshark is empty, missing UDP pack. How long need wait? after set ip ? If i not set brekpoint i, I get on the line
setSn_IR (sn, Sn_IR_TIMEOUT); in function sendto

### Reply 3 by Eugeny, 2019-05-28 (in reply to reply 2)

Maksim:

> If you install breckpins on the socket, the packet is sent

Where’s the code waiting for socket open command completion? Where’s the code waiting for MR’s RST bit to reset after soft reset?

### Reply 4 by Maksim, 2019-05-28

Eugeny:

> Where’s the code waiting for socket open command completion?

into function socket
…
setSn_CR(sn,Sn_CR_OPEN);
while(getSn_CR(sn));
Where’s the code waiting for MR’s RST bit to reset after soft reset?
hardware i wait 1 ms.

### Reply 5 by Maksim, 2019-05-29 (in reply to reply 4)

Maksim:

> waiting for socket open command completion

How i know what socket open (UDP) command completion ? I look Sn_IR(CON) Interrupt only tcp

### Reply 6 by Eugeny, 2019-05-29

Maksim:

> How i know what socket open (UDP) command completion ?

This one

Maksim:

> while(getSn_CR(sn));

waits until command is accepted. Interrupt bits must indicate that command is completed. IMHO.

Maksim:

> Where’s the code waiting for MR’s RST bit to reset after soft reset?
> hardware i wait 1 ms.

After software reset perform checking of the RST bit (7) of MR register for zero, and only then proceed to chip programming.

### Reply 7 by Maksim, 2019-05-30

Eugeny:

> Interrupt bits must indicate that command is completed. IMHO.

I add after while(getSn_CR(sn));
while(1)
{
tmp = getSn_IR(sn);
if(tmp & Sn_IR_CON)
{
setSn_IR(sn, Sn_IR_CON);
break;
}
//M:20131104
//else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT;
else if(tmp & Sn_IR_TIMEOUT)
{
setSn_IR(sn, Sn_IR_TIMEOUT);
return SOCKERR_TIMEOUT;
}
////////////
}
But tmp always zero

### Reply 8 by Eugeny, 2019-05-30 (in reply to reply 7)

Maksim:

> But tmp always zero

Did you operate Sn_IMR properly?

### Reply 9 by Maksim, 2019-05-30

Eugeny:

> Did you operate Sn_IMR properly?

I set Sn_IMR in 0xFF

### Reply 10 by lawrence, 2019-05-30

Hello, Maksim

Did you get no packet from wireshark?

If you have no packet, could you check Sn_IR[SENDOK] after commending Sn_CR[SEND] ?

Before checking the Sn_IR, please set Sn_IMR.

Thank you

### Reply 11 by Eugeny, 2019-05-30

Maksim:

> I set Sn_IMR in 0xFF

SIR/SIMR?

### Reply 12 by Maksim, 2019-05-30

lawrence:

> Did you get no packet from wireshark?

Yes.
If I resend the packet after the timeout, I get a packet in wireshark.
But I want to figure out what I’m doing wrong.

lawrence:

> If you have no packet, could you check Sn_IR[SENDOK] after commending Sn_CR[SEND] ?

I used the official library. Inside the send function there is a check for Sn_IR [SENDOK], but I get Sn_IR_TIMEOUT.

Eugeny:

> SIR/SIMR?

SIR/SIMR=0xFF
IR=0;

### Reply 13 by lawrence, 2019-05-30 (in reply to reply 12)

Hello, Maksim

Maksim:

> If I resend the packet after the timeout, I get a packet in wireshark.
> But I want to figure out what I’m doing wrong.

It is hard to understand. Does it mean it works well after timeout?

Could you share the wireshark from first ARP to the last received UDP packet after timeout?
Maybe we can find something new.

Thank you

---

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