---
title: "W5300 problem in sending TCP packets to PC"
url: "https://maker.wiznet.io/forum/12439"
markdown_url: "https://maker.wiznet.io/forum/12439/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "javad2040"
created: "2017-08-24T13:59:48+09:00"
last_activity: "2020-02-04T07:04:47+09:00"
language: "en"
views: 2862
replies: 24
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# W5300 problem in sending TCP packets to PC

## Question

Asked by javad2040 on 2017-08-24 in Ethernet Chips.

Hi,
I design a PCB board that contain FPGA SPARTAN 6 and W5300. I have initiated the W5300 and i can get a ping from the board.
The problem is that : I can Send TCP packets to w5300 and received by FPGA and store it, but when send same packets to w5300 and PC , the received packets is wrong and is always fixed value (191 29 191 29 …).
I have done every thing that the data sheet says,but the received packet is wrong.
Do you have any Idea what might be wrong? have you seen something similar?

## Replies

### Reply 1 by Eugeny, 2017-08-24

![](https://avatars.discourse-cdn.com/v4/letter/j/f07891/48.png) javad2040:

> but when send same packets to w5300 and PC

Do you mean you send packet *from* W5300 to PC?

![](https://avatars.discourse-cdn.com/v4/letter/j/f07891/48.png) javad2040:

> the received packets is wrong and is always fixed value

As long as it seems packet reaches PC we can deem than all the networking registers are set properly. And the issue is in contents of the packet, thus in the contents of the W5300 TX buffer.

You must check if you -

1. use correct data to put to the TX buffer;

2. use TX buffer (for example not confusing TX and RX buffers), address buffer properly and put data into correct place in the buffer according to the pointers;

3. manage pointers and sizes properly.

### Reply 2 by javad2040, 2017-08-25 (in reply to reply 1)

thank you for reply.
I set all register properly and received packet by FPGA is correct, but received packet by PC is not correct.
Also i check all register and buffer addresses that they are sets correctly, but the problem is exist.
I guess the problem is related to Chip, since i use “How_to_Test_Internal_TX_RX_Memory” document that the testing of TX-FIFO is fails.
please help me to solve this problem.

### Reply 3 by Eugeny, 2017-08-26

![](https://avatars.discourse-cdn.com/v4/letter/j/f07891/48.png) javad2040:

> TX-FIFO is fails

Change your code to test RX-FIFO. Will it fail too?

It would help if you have another board on hand to test your code and see if that another board also fails the test.

### Reply 4 by javad2040, 2017-08-28

I test TX_FIFO and RX_FIFO by sending and receiving data form FPGA that they works correctly.
I don’t another boar for test my code but i decide to change the chip and replace it with another.
have you any suggestion for solving the my problem?

### Reply 5 by Eugeny, 2017-08-29 (in reply to reply 4)

![](https://avatars.discourse-cdn.com/v4/letter/j/f07891/48.png) javad2040:

> I test TX_FIFO and RX_FIFO by sending and receiving data form FPGA that they works correctly.

But one post before you said

![](https://avatars.discourse-cdn.com/v4/letter/j/f07891/48.png) javad2040:

> I guess the problem is related to Chip, since i use “How_to_Test_Internal_TX_RX_Memory” document that the testing of TX-FIFO is fails.

Can you explain please?

### Reply 6 by javad2040, 2017-08-29

For resetting the chip two ways is exist :
1) use reset pin that is hardware reset.
2) use MR(RS) reg that is software reset.
I founded that the chip first should be reset by hardware reset(reset pin) and after initialization it will be ready to use.
Also i founded that for testing the internal Memory, i should used the MR(RS) reg for resetting the chip and **FIFO** .
In previous testing i forgot reset the chip by MR(RS) reg and i used only reset pin that result the testing of TX_FIFO was failure but RX_FIFO was successful.
In last testing after reset the chip by reset pin, i use MR(RS) reg for reset the FIFO that the testing of both FIFO was successful.
Also i use both manner of resetting, but the PC received the incorrect data that seems the TX_FIFO whether gets dummy values or has fixed values that related to the resetting and initialization.
I confused that why TX_FIFO can’t send correct data to PC, since the testing is correct but sending data to PC is fails.

### Reply 7 by Eugeny, 2017-08-29

Let’s consider the whole environment. To achieve result you do the following:

- put data into the W5300 TX buffer, not bigger than TX free size;

- set transmission data size;

- perform send command;

- then packet with data goes through the network;

- packet is received, opened, and data is used.

You should check each stage:

1. ensure you put correct data into the TX buffer (can you take data from wrong location, or use wrong data to put into TX buffer?). Try putting fixed data into TX buffer, for example 0x55, and see if you get 0x55’s at the receiving end. If you will get them, then you most probably put wrong data into the buffer;

2. ensure you put right data size, and perform send command to the correctly configured socket (and to the right socket);

3. you can use Wireshark to intercept packets on the network to see what W5300 sends and examine packets’ contents. Set up Win or Linux host as network bridge and install Wireshark on it;

4. last, but not least - PC with receiving software may mess the data. Are you sure it handles received data properly?

### Reply 8 by javad2040, 2017-09-05

hi.
Dear “Eugeny” thank you for helping.
I Checked the Register’s Data carefully and i founded that MTYPER reg (specially TX_FIFO ) is not set correctly, i set it correctly and the problem solved but new problem is appears.
I send 512 byte data from PC to W5300 that it saved to FPGA correctly but when read it from w5300, the two first of received data is zero or dummy value. I set the registers according below:
RMS01R_Data := X"0040";
RMS23R_Data := X"0000";
RMS45R_Data := X"0000";
RMS67R_Data := X"0000";
TMS01R_Data := X"0040";
TMS23R_Data := X"0000";
TMS45R_Data := X"0000";
TMS67R_Data := X"0000";
MTYPER_Data := X"00FF";
I use Socket 1, direct mode, 16 bit data bus, big-endian, TCP Server mode, TX and RX FIFO is 64KB.
Also i set MSSR(MTU) reg to 1460 byte but the new problem exist.
can you help me to solve it?

### Reply 9 by Eugeny, 2017-09-06

![](https://avatars.discourse-cdn.com/v4/letter/j/f07891/48.png) javad2040:

> the two first of received data is zero or dummy value.

Did you see figure 11 on the page 96 of [datasheet](http://www.wiznet.io/wp-content/uploads/wiznethome/Chip/W5100/Document/W5300_DS_V132E.pdf)? It says that first two bytes might be the packet-info (data size).

### Reply 10 by javad2040, 2017-09-07

yes i saw the figure and use the S1_MR(Align) and S1_RX_RSR for receiving the Data only.
The received data by FPGA is true but when the same data sent to PC, the two first byte is added to data that i force read (2+data) bytes for retrieve the data.

### Reply 11 by Eugeny, 2017-09-07

Two things you need to check:

- if you are not mistakenly put these 2 bytes into the TX buffer for sending;

- that you strictly follow “ESTABLISHED : Send DATA ? / Sending Process” chapter of the datasheet.

### Reply 12 by dehghan, 2018-04-12

Hi javad2040
I have problem something like you the send data to PC is correct but when I send data from PC to w5300 the data is incorrect .
I want to know how you solve your problem?
Regards. Dehghan

### Reply 13 by javad2040, 2018-04-13 (in reply to reply 12)

Hi dehghan
please explain more about your problem.

### Reply 14 by dehghan, 2018-04-13

Dear Javad your name look like Iranian name. If it’s OK we can speak Farsi.

### Reply 15 by javad2040, 2018-04-14

yes i agree

### Reply 16 by dehghan, 2018-04-14

My mobile number is 09125671038 if it’s possible give me your mobile number.

### Reply 17 by tandis, 2020-02-02

Hi! I also have problem in listening mode. I send the listen command but my ssr doesn’t change to x14. what is the problem?

### Reply 18 by becky, 2020-02-03

What is the current ssr value?

### Reply 19 by tandis, 2020-02-03

it shows 0x00.
I also dont know what is my port destination number,.

### Reply 20 by becky, 2020-02-03 (in reply to reply 19)

Did you send OPEN command before send listed command?
Please refer to 5.2.1.1 TCP SERVER(page 95 on W5300 Datasheet).

[wiznet.io](https://www.wiznet.io/wp-content/uploads/wiznethome/Chip/W5300/Documents/W5300_DS_V134E.pdf)

<https://www.wiznet.io/wp-content/uploads/wiznethome/Chip/W5300/Documents/W5300_DS_V134E.pdf>

### [W5300_DS_V134E.pdf](https://www.wiznet.io/wp-content/uploads/wiznethome/Chip/W5300/Documents/W5300_DS_V134E.pdf)

2.03 MB

And you don’t need to set destination port number if you use TCP server.
Because TCP server waits connection of Client.
But you need to set source port register.

[![image](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/d/d49353274e726953881bd29b0fc443e83cff7911.png) image593×536 33.8 KB](https://maker.wiznet.io/forum_uploads/wiznet/original/2X/d/d49353274e726953881bd29b0fc443e83cff7911.png)

### Reply 21 by tandis, 2020-02-04

yes, I open the socket as TCP and I also get the 0x13 on SSR as response, but when I send listen command SSR changes to zero. I set source port , source and destination MAC address,but I didn’t set MYTPER , RX_RSR , TX_RSR. What is the problem?

### Reply 22 by becky, 2020-02-04 (in reply to reply 21)

Does SSR value change from 0x13 to 0x00 when you send listen command?
Can you give me your code?
I think that can quickly solve your problem.

Sn_RSR is only read register so you don’t set the register.
And i don’t konw MYTPER and TX_RSR register.
Please let me know accurate register name.

### Reply 23 by tandis, 2020-02-04

I will send my files right now

### Reply 24 by tandis, 2020-02-04

[w5300.zip](https://maker.wiznet.io/forum/legacyFile.asp?path=kLBP23nWnX4Bh3nFArtx1bDE0D3.zip) (7.9 KB)
There are 2 files which are VHDL code for Spartan6. One of the files is package for defining registers address and data, the other one is the main code. I am looking forward to your reply. Thank you

---

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