diff --git a/idle.ino b/idle.ino index f522b94..7683919 100644 --- a/idle.ino +++ b/idle.ino @@ -45,7 +45,7 @@ void initialiseIdle() idle2_pin_port = portOutputRegister(digitalPinToPort(pinIdle2)); idle2_pin_mask = digitalPinToBitMask(pinIdle2); idle_pwm_max_count = 1000000L / (16 * configPage3.idleFreq * 2); //Converts the frequency in Hz to the number of ticks (at 16uS) it takes to complete 1 cycle. Note that the frequency is divided by 2 coming from TS to allow for up to 512hz - TIMSK4 |= (1 << OCIE4C); //Turn on the A compare unit (ie turn on the interrupt) + TIMSK4 |= (1 << OCIE4C); //Turn on the C compare unit (ie turn on the interrupt) break; case 3: diff --git a/scheduler.ino b/scheduler.ino index a7596a6..ae44581 100644 --- a/scheduler.ino +++ b/scheduler.ino @@ -121,7 +121,6 @@ void setIgnitionSchedule1(void (*startCallback)(), unsigned long timeout, unsign { if(ignitionSchedule1.Status == RUNNING) { return; } //Check that we're not already part way through a schedule - //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 4uS (Time per Tick = (Prescale)*(1/Frequency)) if (timeout > 262140) { return; } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65525), the timer compare value will overflow when appliedcausing erratic behaviour such as erroneous sparking. OCR5A = TCNT5 + (timeout >> 2); //As there is a tick every 4uS, there are timeout/4 ticks until the interrupt should be triggered ( >>2 divides by 4) @@ -136,7 +135,6 @@ void setIgnitionSchedule2(void (*startCallback)(), unsigned long timeout, unsign { if(ignitionSchedule2.Status == RUNNING) { return; } //Check that we're not already part way through a schedule - //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 4uS (Time per Tick = (Prescale)*(1/Frequency)) if (timeout > 262140) { return; } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65525), the timer compare value will overflow when applied causing erratic behaviour such as erroneous sparking. OCR5B = TCNT5 + (timeout >> 2); //As there is a tick every 4uS, there are timeout/4 ticks until the interrupt should be triggered ( >>2 divides by 4) @@ -151,7 +149,6 @@ void setIgnitionSchedule3(void (*startCallback)(), unsigned long timeout, unsign { if(ignitionSchedule3.Status == RUNNING) { return; } //Check that we're not already part way through a schedule - //We need to calculate the value to reset the timer to (preload) in order to achieve the desired overflow time //The timer is ticking every 4uS (Time per Tick = (Prescale)*(1/Frequency)) if (timeout > 262140) { return; } // If the timeout is >4x (Each tick represents 4uS) the maximum allowed value of unsigned int (65525), the timer compare value will overflow when applied causing erratic behaviour such as erroneous sparking. OCR5C = TCNT5 + (timeout >> 2); //As there is a tick every 4uS, there are timeout/4 ticks until the interrupt should be triggered ( >>2 divides by 4)