Interrupt driven actions

Hello, i am making a very time critical program that controls 2 drivers with PID, and is monitored via Ethernet using the modbus protocol.

the w5100 datasheet states that if i write the Interrupt Mask Register (IMR) to 0xEF (or 11101111) interrupts will pass through to the INT pin of the chip to the D2 pin of arduino (interrupt 0), i have bridged this connection but i still dont get any interrrupts.

first of all the program reads the IMR, then it writes it with 0x0EF, then it reads it again to certify it has been written.

then in the loop it reads the Interrupt register, in the datasheet says that when an interrupt event happens it will be written in this register and that it should be read to know what hapenned. it also says that it has to be cleared once and interrupt happens.

once an interrupt happens (it never does) the variable number increments and is printed to know its value.

the INT pin of the chip has also been bridged to the D2 pin of the Mega board.

what am i missing?

this program is only an example that im trying to make work, its not using modbus at all, what im doing is sending pings, or disconnecting the cable from the arduino to check for interrupts.

#include <SPI.h>
#include <Ethernet.h>
#include <utility/w5100.h>

volatile int number = 0;
void setup(){
    attachInterrupt(0, mbInterrupt, FALLING);
    uint8_t mac[]     ={0x90,0xA2,0xDA,0x00,0x52,0x01    };
    uint8_t ip[]      ={192,168,0,101    }; 
    pinMode(42, OUTPUT);
    byte oldRead =W5100.readIMR();
    Serial.print(" Default IMR: ");
    byte newRead =W5100.readIMR();
    Serial.print(" New IMR: ");

void loop(){
    byte irRead = W5100.readIR();
    Serial.print("IR: ");

void mbInterrupt(){

After several tries more and on my third day on trying to make this happend i managed to find a solution for anyone that is trying to to do the same.

in the setup i added these two lines

  EthernetServer server3(502);            //502 is the port im sending data to.

and on the interruption routine im adding these three lines


theres still work to do, and the interruptions have to be managed but at least they are happening.