I don’t quite understand the way of using RECV command in S0_CR register.
Suppose there are 1000 bytes of data in the internal RX memory, but I only want to extract 256 bytes of data for now. So, when is the proper time to send RECV command? Is it just after extracting 256 bytes of data? Or perhaps it has to be the time when all the 1000 bytes are extracted?
Read W5100’s datasheet on the algorithms and how to handle buffers.
Any time can be proper time for application. If there’s free space in RX buffer, incoming data will be placed into the buffer. If there’s no space in the buffer, then RECV will do nothing. Thus it is in your interest to free buffer as quick as possible.
You can extract byte count less than currently indicated by received data size, and you should set new pointer accordingly (+256 bytes). Then, if you issue RECV command, those 256 byte space will be considered as “free” for new data.
Again, keeping data in the buffer you risk to miss new data (in case of UDP). But generally you can extract by 1 byte, and every time use RECV command to receive one further byte. Also keep in mind that it is a killer from performance perspective. The bigger size of data you move and “free”, the faster everything works.