function attachInterrupt

Hello,
i have a problem with the attachInterrupt function.
When the time between two impulsion is under 15ms, the arduino block and stop everythings.
Is there a minimum time for this function ?

(PS: Sorry if my english is no good !)

Thanks
Crapsy

It is no way as long as 15mS. It is a lot shorter in the order of four or fice clock cycles. A lot depends on what the interrupt service routine is doing.

Why not post your code?

Mark

Thank you for the answer !
My prog increment a constant when there are a switch on the rotary encoder.
If the time between two switch it's shorter than 150ms, the value increment of 5.
With this prog i have tested and if i put the time under 15-13 ms the prog stop.
I don't understand why !
If you want test this prog you put juste two wire, one of the pin 2 to 8 and the other of the pin 3 to 9.

int nVal = 0; 

int time =100;

int tempsCodeurPre;
int tempsCodeur;

void setup(){
  
pinMode(2, INPUT);
pinMode(3, INPUT);


pinMode(8, OUTPUT);
pinMode(9, OUTPUT);

attachInterrupt(0, nAnalyse, CHANGE);

Serial.begin(9600);
Serial.println("Start");
} 

void loop(){
  
//time=100/((millis()/1000)+2);
  time=200;
  Serial.print("  Time :  ");
  Serial.print(time);
  Serial.print("  Val :  ");
  
  digitalWrite(8,LOW);
  digitalWrite(9,LOW);
  delay(time);
  digitalWrite(8,HIGH);
  digitalWrite(9,LOW);
  delay(time);
  Serial.print("          ");
  digitalWrite(8,HIGH);
  digitalWrite(9,HIGH);
  delay(time);
  digitalWrite(8,LOW);
  digitalWrite(9,HIGH);
  delay(time);
  Serial.println("          ");
  
} 


void nAnalyse()
{  
if((tempsCodeur-tempsCodeurPre)<150)
 { 
   
  if(digitalRead(2) == digitalRead(3))
    {    
      nVal=nVal+5;
    }
  else
    {    
      nVal=nVal-5;  
    } 
 } 
 
 else
 { 
  if(digitalRead(2) == digitalRead(3))
    {    
      nVal++;
    }
  else
    {    
      nVal--;  
    } 
  }
  
  tempsCodeurPre=tempsCodeur;
  tempsCodeur=millis();

 Serial.print(nVal);
  }

Serial.print will not work in an Interrupt Service Routine (ISR). I don't think millis() will either.

Yes, now my prog is OK !
i have just put my variable in volatile and remove Serial.print.

thank you very much
It's very cool to post an question on this forum, it's fast and thy guy are very nice.

If you want test this prog you put juste two wire, one of the pin 2 to 8 and the other of the pin 3 to 9.

where are your pull up/down resistors! You seem to have floating inputs

Mark

Like i put the output directly on the input i thing it's ok, because every time the inut are supply, there are no floating moment.
But it's just for the test in really i have put Pull-Up resistors on the rotary encoder.

groundfungus:
Serial.print will not work in an Interrupt Service Routine (ISR). I don't think millis() will either.

millis() works, it doesn't try waiting, just looks at a few registers. delay() is the one
you must never call in an ISR.