Strange behavior of interrupts INT0 and INT1 pin 2 and 3

I need to use YUN as a pulse counter. I noticed a strange behavior of interrupts INT0 and INT1 of Arduino YUN (and I think also Arduino Leonardo) compared to an Arduino UNO . I've done following tests : 1) UNO receives on pin 2 (INT0) and pin 3 (INT1) pulses transmit from YUN pin 12 and 13. The YUN pin 12 sends about 226 pulses every 5 seconds, the pin 13 about 43 pulses every 5 seconds. The UNO card correctly reads the number of pulses received , 226 on pin 2 (INT0) and 43 on pin 3 (INT1)

The YUN serial output is: SEND pin 12 = 226 - pin 13 = 43

The ONE serial output is: RECEIVE INT0 = 226 - INT1 = 43

2) YUN receives on pin 3 (INT0) and pin 2 (INT1) pulses from UNO pin 12 and 13. The UNO pin 12 sends about 226 pulses every 5 seconds, the pin 13 about 43 every 5 seconds. The YUN correctly reads the number of pulses received on pin 3 (INT0), but on pin 2 (INT1) YUN seems to read 43 pulses from UNO pin 13 of the UNO card plus half of 226 pulses from UNO pin 12!

The ONE serial output is: SEND pin 12 = 226 - pin 13 = 43

The YUN serial output is: RECEIVE INT0 = 226 - INT1 = 155

3)Same of test 2, but the ONE pin 12 and pin 13 both transmit about 226 pulses every 5 seconds. YUN correctly reads the number of pulses received.

The YUN serial output is: RECEIVE INT0 = 226 - INT1 = 226

4) Same of test 2 using YUN INT4 on pin 7 instead of INT1. YUN correctly reads the number of pulses received.

The YUN serial output is: RECEIVE INT0 = 226 - INT4 = 43

Actually i'm not skilled with the whole Arduino interrupts thing. How can I use YUN interrupts without those problems?

This is sketch i used to send pulses

//send

long mills12 = 0;// will store last time pin 12 was updated
long mills13 = 0;// will store last time pin 13 was updated
long period12 = 10; //pulse period in milliseconds on pin 12
long period13 = 57; //pulse period on pin 13
long count12 = 0;
long count12p = 0;
long count13 = 0;
long count13p = 0;
unsigned long curtime = 0;
long timez = 0;// will store last time send count out
long period = 5000;// every 5 seconds out count value

void setup()  
{
  pinMode(12, OUTPUT); 
  pinMode(13, OUTPUT); 
  Serial.begin(9600);
}

void loop() {
  curtime= millis();
  if(curtime - mills12 > period12) {
    digitalWrite(12, !digitalRead(12)); 
    mills12 = millis(); 
    count12++;
  }
  if(curtime - mills13 > period13) {
    digitalWrite(13, !digitalRead(13)); 
    mills13 = millis(); 
    count13++;
  }
  if(curtime - timez > period) {
    Serial.print("SEND pin 12 = "); 
    Serial.print((count12 - count12p)/2); 
    Serial.print(" - pin 13 = "); 
    Serial.println((count13 - count13p)/2); 
    timez = millis();
    count12p = count12;
    count13p = count13;
  }
}

This is sketch i used to read pulses

//receive
volatile long countINT1 = 0;
volatile long countINT1p = 0;
volatile long countINT0 = 0;
volatile long countINT0p = 0;
int intINT0 = 0;
int intINT1 = 0;
unsigned long curtime = 0;
long timez = 0;// will store last time send count out
long period = 5000;// every 5 seconds out count value

void setup()  
{
  Serial.begin(9600);
  attachInterrupt(0, addcountINT0, FALLING); 
  attachInterrupt(1, addcountINT1, FALLING); 
}

void loop()
{
  curtime = millis();
  if(curtime - timez > period) {
        intINT0 = countINT0 - countINT0p;
        intINT1 = countINT1 - countINT1p;
    Serial.print("RECEIVE INT0 = "); 
    Serial.print(intINT0); 
    Serial.print(" - INT1 = "); 
    Serial.println(intINT1); 
    timez = millis();
    countINT0p = countINT0;
    countINT1p = countINT1;
  }
}
void addcountINT0() {
    countINT0++;
}

void addcountINT1() {
    countINT1++;
}

http://arduino.cc/en/Reference/SoftwareSerial

Not all pins on the Leonardo (Yun) support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

sonnyyu: http://arduino.cc/en/Reference/SoftwareSerial

Not all pins on the Leonardo (Yun) support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

Yes, but i'm talking of external interrupt int0 and int1: it seems that the pulses received on INT0 are also (partially) read by INT1

I'm facing the same problem. I have two pulse counters on INT0 ant INT1. INT0 seems to count ok, but INT1 seems to count too much. Anyone have found something about these interrupts problems?

I've been experimenting with a four pin fan controller based on the Leonardo. I want to read three fans and control two of those accordingly. So I've hooked up the three fans to INT0, INT1 and INT6. I then wanted to use PWM to control the two fans which are hooked up to INT0 and INT1.

I too have had issues with INT0 and INT1. What I've discovered is INT1 will count too much but ONLY if I use PWM on two pins that share the same TIMER. Initially this was 9 and 10. I assume there's some clash of TIMER1 and INT1 and how PWM works there. I haven't studied the ATMega 32U4 datasheet much, so this is just a guess. I changed the pins I used for PWM to Pins 5 and 9 and all is well again.

Hope this helps.

LaesQ