I need to measure pulse width (not time between two pulses, but length of one single pulse - from raising to falling) on fuel injector - it is driven by simple square pulse on ground wire (positive wire is allways attached to battery's +)
Can i assign TWO interrupts to ONE pin? i tried this:
int injPin = 3; //Pin connected to injector's ground wire
volatile unsigned long injTime1; //Time of front raising
volatile unsigned long injTime2; //Time of front falling
unsigned long injTime;
void setup()
{
pinMode(injPin, INPUT);
digitalWrite (injPin, HIGH); //Pull-up pin - as our injector is driven by connecting it to ground, i suppose i need to pull-up pin to get it's value as 1 when injector is turned off
attachInterrupt(1, up, RAISING); //interrupt on raising front
attachInterrupt(1, down, FALLING); //interrupt on falling front
}
void loop()
{
//some code
}
void down()
{
injTime1 = micros(); //get time of pulse going down
}
void up()
{
injTime2 = micros(); //get time of pulse going up
injTime = injTime2 - injTime1; //measure time between down and up (so it will be time between ground appearing ot pulled-up pin, and ground disappearing)
}
but my "down" (on falling) interrupt didn't fired even when i removed pull-up - can i use 2 interrupts on 1 pin, or i need to shortcut another interrupt-enabled pin (pin 2 to pin 3) and use two pins for two interrupts?
maybe someone will purpose some simple external logic to measure pulse width?
thanks!
