View Single Post
Old 08-30-2013, 01:03 PM   #20 (permalink)
t vago
MPGuino Supporter
 
t vago's Avatar
 
Join Date: Oct 2010
Location: Hungary
Posts: 1,807

iNXS - '10 Opel Zafira 111 Anniversary

Suzi - '02 Suzuki Swift GL
Thanks: 829
Thanked 708 Times in 456 Posts
Quote:
Originally Posted by nickdigger View Post
Did you have to do any debouncing-type of trick for this? I tried switching to the CHANGE trigger, and wondered if it failed because the level hadn't yet fully risen to "high" when the int fired.
Nope. All I had to do was to be able to read pin D, and act on it.

Code:
	uint8_t injDir = (PIND ^ injDirection) & (1 << PIND2);

	if (injDir) { // handle fuel injector opening event

...

	} else { // handle fuel injector closing event

...

	}
injDirection is a volatile uint8_t which is set to either 0x00 or 0xFF, depending on the state of the injector edge trigger flag parameter.

Quote:
Originally Posted by nickdigger View Post
I think the space savings was only about 80 bytes, by combining the interrupts, but potentially the free pin could be more valuable.
Indeed. Every little bit helps, and that interrupt pin is now freed up for other things.
  Reply With Quote