Fix for potential fuel timing issue on injector ch 4

This commit is contained in:
Josh Stewart 2016-08-31 16:54:36 +10:00
parent 2d631211b0
commit f3df4a072f
1 changed files with 2 additions and 2 deletions

View File

@ -137,8 +137,8 @@ void setFuelSchedule4(void (*startCallback)(), unsigned long timeout, unsigned l
//We need to calculate the value to reset the timer to (preload) in order to achieve the desired overflow time
//As the timer is ticking every 16uS (Time per Tick = (Prescale)*(1/Frequency))
//unsigned int absoluteTimeout = TCNT4 + (timeout / 4); //Each tick occurs every 4uS with the 128 prescaler, so divide the timeout by 4 to get ther required number of ticks. Add this to the current tick count to get the target time. This will automatically overflow as required
fuelSchedule4.startCompare = TCNT4 + (timeout >> 2);
fuelSchedule4.endCompare = fuelSchedule4.startCompare + (duration >> 2);
fuelSchedule4.startCompare = TCNT4 + (timeout >> 4);
fuelSchedule4.endCompare = fuelSchedule4.startCompare + (duration >> 4);
OCR4B = fuelSchedule4.startCompare; //Use the C copmare unit of timer 3
fuelSchedule4.duration = duration;
fuelSchedule4.StartCallback = startCallback; //Name the start callback function