Which pin do you plan on using to trip the interrupt?
Assuming the pulse goes high (maybe PortB.0?), let the ON INTERRUPT kick you into the interrupt subroutine and stay there until the pin goes low so you don't kick the counter more than once.
Check and reset the pulse counter (if counter > 4000 then = 0 etc.etc.) and increment the mileage counter, and do the displaying and button checking in your main loop. No sense doing that in your interrupt subroutine.
First off though, don't worry about counting mileage...put the whole thing together and whip up a 555 timer or something (maybe even a pushbutton, the switch bounce will give you more than one pulse if the button is old enough!) to simulate the VSS pulse and get the display and everything working without having to go out to the car every 2 minutes to test it out. Just get the thing counting up as you need it (heck you can get both an odometer and speedometer and average speedometer and gas mileage and oil change intervals and all sorts of crap into this), then worry about all the neat stuff for later since you've already got basics down.




Bookmarks