---
title: "Issue with W5500 hardware interrupt"
url: "https://maker.wiznet.io/forum/13832"
markdown_url: "https://maker.wiznet.io/forum/13832/md"
type: "Forum topic"
category: "Ethernet Chips"
author: "xshura"
created: "2020-05-14T00:16:05+09:00"
last_activity: "2021-06-09T22:06:24+09:00"
language: "en"
views: 1282
replies: 3
source: "WIZnet Makers forum (https://maker.wiznet.io/forum/)"
---

# Issue with W5500 hardware interrupt

## Question

Asked by xshura on 2020-05-14 in Ethernet Chips.

I need to catch incoming TCP packets by interruption.

I have implemeneted following :

1. In the loop, I invoke the register check procedure Sn_IR (Sn_IMR = 0x1F);

2. If the RECV = 1 bit in the Sn_IR register, at the first I call a procedure for reading the packet and after the procedure for sending the response packet;

3. After reading a packet and sending the response, the Sn_IR register automatically resets to 0x00;
   That’s how it works.

Now, If I turn on the hardware interrupt, I have did following:

1. Chip initialization procedure sets the register SIMR = 0xFF (although only one socket is used);

2. Interrupt procedure check the RECV bit in the Sn_IR register. If bit RECV = 1 then set the flag FL_INT_RECV and leave the interrupt;

3. In the loop:
   A procedure of flag FL_INT_RECV verification invokes. If the flag is set, then a procedure calls for reading the packet, sending the response packet and reset flag
   by resetting the interrupt bits:

- setSIR (0x00);

- setSn_IR (SOCK_TCP, 0x1F);

In doing so, I receive one packet and can send one response only. The INT line stays low (SIR != 0x00, Sn_IR != 0x00).
What I am doing wrong? Please, I will be thankful for any suggestions.
Thank!

## Replies

### Reply 1 by becky, 2020-05-25

I recommend you set Sn_IMR to 0x04. If so, the interrupt occurs only when it is recv, so there is no need to check if it is a recv interrupt when the interrupt occurs.

setSIR (0x00) is meaningless. SIR is automatically cleared according to Sn_IR. If you did setSn_IR (SOCK_TCP, 0x1F), the interrupt is cleared and the INT line should go high. If setSn_IMR (0xff) is set and you set setSn_IR (SOCK_TCP, 0x1F) in recv only, interrupts may occur in other bits and thus may not be cleared. This can be solved by setting 0x04 in sn_imr.

### Reply 2 by xshura, 2020-06-05 (in reply to reply 1)

Thanks for your reply. Everything works fine now!
Do I understand correctly that I only need to reset the bit in the Sn_IR register that raised an interrupt?

### Reply 3 by Deepak, 2021-06-09 (in reply to reply 1)

Hi,
How can I implement a callback function to receive incoming data ??

---

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