W5200 TCP Client - Data arrives corrupted
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: W5200 TCP Client - Data arrives corrupted
by Eugeny ·
Do you wait for socket’s send command completion (by waiting for CR to become zero) before doing anything else with the socket?
RE: RE: W5200 TCP Client - Data arrives corrupted
by Eugeny ·
The question I asked is:
and you answered some other question.
RE: W5200 TCP Client - Data arrives corrupted
by EdiWiz ·
Yes, in the code I did not copy it but before send command I clear interrupts:
In my log-UART I verify Sn_CR = 0 before send process.
What I don’t understand is why in the dst_ptr address I read (only for check) the buffer that I just wrote in the TX memory and it’s OK but altered data arrives on the PC server.
RE: W5200 TCP Client - Data arrives corrupted
by EdiWiz ·
When I send the command SEND(0x20) to Sn_CR I wait until interrupt occurs (bit SEND_OK of Sn_IR), In this way I know that the SEND command is completed and so I can just send a new package.
Also, every time I send a package (just before the send process), I monitor the most important registers like Sn_CR and I always read Sn_CR=0.
RE: RE: W5200 TCP Client - Data arrives corrupted
by Eugeny ·
In addition, to this action, put a check for CR being 0, do it just after SEND command is issued.
RE: W5200 TCP Client - Data arrives corrupted
by EdiWiz ·
I have added the check Sn_CR=0 just after SEND command and also added just before start send process but still the same.
As I said sometimes I disconnect the power supply and re-feed the board and the data starts to arrive correctly to the server, but sometimes the data arrives wrong.
Maybe it’s my initialization process? My initialization TCP Client:
RST_pin_LOW
delay 1ms
RST_pin_HIGH
delay 1second
set SHAR, GAR, SUBR, SIPR, Sn_PORT, Sn_MR=TCP, Sn_CR=OPEN
wait SOCK_INIT
set Sn_DIPR, Sn_DPORT, Sn_TXMEM_SIZE=0x0800, Sn_CR=CONNECT
if( SOCK_ESTABLISHED && Sn_CR==0)
send_process
…
RE: RE: W5200 TCP Client - Data arrives corrupted
by Eugeny ·
Good, so it is not a SEND commend process being corrupt.
I did not find any problem in the code.
Increase reset low to 1 second as a test.
Assuming you write proper value into the respective register (0x2 into 0x401f). As a test, please remove the code modifying memory size registers (as you set it to the default value of 2k) and see if it will change anything.
Can you identify any pattern in the data corrupt and in the regularity of the data corruption? Send one fixed string and log everything coming from the W5200, get significant amount of data and then analyze the patterns. For example - corrupt data is always corrupt in the same manner, corruption always happens in fixed period.
You can even send not just arbitrary text, but specific information - e.g. send pointers and data amount being sent so that you can check then at another end (in PC log).
RE: W5200 TCP Client - Data arrives corrupted
by EdiWiz ·
I finally found the problem and thank you so much for helping me find it Eugeny. I was writing to the Sn_TXMEM_SIZE the value 0x0800 (2K) instead of 0x02 (uint16_t instead of uint8_t). Now, after connecting and disconnecting several times the board, the data arrives correctly to the server.
Thank you very much dear friend Eugeny.