Transmission corrupt


I am using W5500 as TCP server.
For transmitting data from server I carry out the following steps

  1. Read the Sn_TX_RD.
  2. Using the values of Sn_TX_RD, I write 6 bytes of data to the TX_buffer.
    3.Then i update the value of Sn_TX_WR by adding 6 to it.
  3. Then I issue the SEND command.
    5.And repeat again from the 1st step.

However I find that the data transmitted is mostly corrupt.

And if i write just 2 bytes in the Tx_Buffer and send, the data is corrupted but rarely. But this would decrease my efficiency.

Is there any solution for this ?

  1. read TX_FSR to see if there’s free space in the TX buffer
  2. read TX_WR, and write data to the buffer using mask respective for the buffer size
  3. update TX_WR with unmasked pointer (e.g. ef00 + 6 = ef06)
  4. issue SEND command
  5. wait until command register becomes 0 (command completed)
    6, go to step 1 if there’s still data to send