pulsein() bug?

hi
I am not able to read LOW pulse duration with PULSEIN(), have find this topic with same problem
http://arduino.cc/forum/index.php/topic,86039.0.html

any suggestion

stefano

long val;
unsigned long durata;
int elemento=2;

void setup() 
{

  val=0;
  durata=0;
   pinMode(elemento,INPUT);

   Serial.begin(9600);
}

void loop()
{
  noInterrupts();
   durata=pulseIn(elemento,LOW,500);

  if (durata>5) 
  {

   val++;

      Serial.print("d ");
    Serial.println(durata);
    Serial.print("val ");
  Serial.println(val);

  }
}

Try not disabling interrupts.

pulseIn() needs timer0.

hi
@jamesc4s, this version is the last, but also without noInterrupts(), not working

stefano

You are giving the pulse 500 uS to start. Does the pulse come that quickly? How can you be sure?

hi
@Nick Gammon my pulse train is 10ms Low, 36ms High, have you experience with pulsein(), can you show me some sketch

stefano

Well, 500 uS is 0.5 mS. Try omitting the timeout.