---
title: "Using Sn_IR RECV bit instead of Sn_RX_RSR"
url: "https://maker.wiznet.io/forum/9617"
markdown_url: "https://maker.wiznet.io/forum/9617/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "ags"
created: "2013-10-07T05:49:50+09:00"
last_activity: "2017-05-04T08:30:12+09:00"
language: "en"
views: 592
replies: 1
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Using Sn_IR RECV bit instead of Sn_RX_RSR

## Question

Asked by ags on 2013-10-07 in Ethernet Chips.

I have written drivers for the W5100 chip. I use the Sn_IR RECV bit to sense when new data has been received. For UDP packets, I read the packet length (offset 6 and 7 bytes from the packet start) and with that information I process the UDP packet. I then clear the Sn_IR RECV bit by writing ‘1’. I update the Sn_RX_RD value (incrementing by the packet length, plus the 8 bytes for the UDP packet header), and finally complete the receive operation by sending the RECV command (0x40) to Sn_CR.

For the W5100, if there is more received data (either new or that was already received when I checked the Sn_IR RECV bit) the Sn_IR RECV bit is again asserted (==‘1’) after the RECV command. In this way, I can reliably use the socket receive interrupt to sense data.

The datasheet for the W5200 suggests using the Sn_RX_RSR register to determine when data has been received. It specifically points to potential problems using Sn_IR RECV. Does the W5200 function differently than the W5100 in this way? Am I correct that if I do not process all received data, or if new data arrives during processing, after the RECV command is sent, Sn_IR RECV bit will again be set?

## Replies

### Reply 1 by hjjeon0608, 2013-10-14

Hi, ags.

W5100 and W5200 are same structure. So receiving process should be same.

And when receive data if you do not process prior received data, Sn_IR(recv) isn’t set as 1 after clearing Sn_IR(recv) bit automatically. It is overlapped.

So, we recommend using Sn_IR and Sn_RX_RSR both.

Best regards.

---

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