Minor timing protections

This commit is contained in:
Josh Stewart 2015-06-05 23:30:37 +10:00
parent b6870db816
commit d35164c46f
6 changed files with 265 additions and 98 deletions

View File

@ -36,11 +36,10 @@ void triggerPri_missingTooth()
{
// http://www.msextra.com/forums/viewtopic.php?f=94&t=22976
// http://www.megamanual.com/ms2/wheel.htm
noInterrupts();
curTime = micros();
curGap = curTime - toothLastToothTime;
if ( curGap < triggerFilterTime ) { interrupts(); return; } //Debounce check. Pulses should never be less than triggerFilterTime, so if they are it means a false trigger. (A 36-1 wheel at 8000pm will have triggers approx. every 200uS)
if ( curGap < triggerFilterTime ) { return; } //Debounce check. Pulses should never be less than triggerFilterTime, so if they are it means a false trigger. (A 36-1 wheel at 8000pm will have triggers approx. every 200uS)
toothCurrentCount++; //Increment the tooth counter
//High speed tooth logging history
@ -56,7 +55,7 @@ void triggerPri_missingTooth()
if(configPage2.triggerMissingTeeth == 1) { targetGap = (3 * (toothLastToothTime - toothLastMinusOneToothTime)) >> 1; } //Multiply by 1.5 (Checks for a gap 1.5x greater than the last one) (Uses bitshift to multiply by 3 then divide by 2. Much faster than multiplying by 1.5)
//else { targetGap = (10 * (toothLastToothTime - toothLastMinusOneToothTime)) >> 2; } //Multiply by 2.5 (Checks for a gap 2.5x greater than the last one)
else { targetGap = ((toothLastToothTime - toothLastMinusOneToothTime)) * 2; } //Multiply by 2 (Checks for a gap 2x greater than the last one)
if ( curGap > targetGap )
if ( curGap > targetGap || toothCurrentCount > triggerActualTeeth)
{
toothCurrentCount = 1;
toothOneMinusOneTime = toothOneTime;
@ -67,7 +66,7 @@ void triggerPri_missingTooth()
toothLastMinusOneToothTime = toothLastToothTime;
toothLastToothTime = curTime;
interrupts();
//interrupts();
}
void triggerSec_missingTooth(){ return; } //This function currently is not used
@ -83,8 +82,10 @@ int getRPM_missingTooth()
int getCrankAngle_missingTooth(int timePerDegree)
{
//This is the current angle ATDC the engine is at. This is the last known position based on what tooth was last 'seen'. It is only accurate to the resolution of the trigger wheel (Eg 36-1 is 10 degrees)
noInterrupts();
int crankAngle = (toothCurrentCount - 1) * triggerToothAngle + configPage2.triggerAngle; //Number of teeth that have passed since tooth 1, multiplied by the angle each tooth represents, plus the angle that tooth 1 is ATDC. This gives accuracy only to the nearest tooth.
crankAngle += ( (micros() - toothLastToothTime) / timePerDegree); //Estimate the number of degrees travelled since the last tooth
interrupts();
if (crankAngle > 360) { crankAngle -= 360; }
return crankAngle;

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<msq xmlns="http://www.msefi.com/:msq">
<bibliography author="TunerStudio MS 2.6.14 - EFI Analytics, Inc." tuneComment=" &#10;&#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; " writeDate="Fri May 29 00:11:09 EST 2015"/>
<versionInfo fileFormat="4.0" firmwareInfo="" nPages="3" signature="20"/>
<bibliography author="TunerStudio MS 2.6.14 - EFI Analytics, Inc." tuneComment=" &#10;&#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; &#10; " writeDate="Fri Jun 05 23:29:20 EST 2015"/>
<versionInfo fileFormat="4.0" firmwareInfo="Bowling &amp; Grippo MS1 Base Code 20" nPages="7" signature="20"/>
<page>
<pcVariable name="tsCanId">"0"</pcVariable>
<pcVariable cols="1" digits="1" name="wueAfrTargetOffset" rows="10" units=":1">
@ -41,37 +41,63 @@
71.0
</pcVariable>
</page>
<page number="0" size="128">
<constant cols="8" digits="0" name="veTable" rows="8" units="%">
27.0 27.0 27.0 27.0 27.0 27.0 27.0 27.0
29.0 32.0 33.0 35.0 36.0 36.0 36.0 36.0
35.0 37.0 38.0 39.0 41.0 46.0 46.0 46.0
46.0 53.0 55.0 56.0 56.0 56.0 55.0 55.0
59.0 64.0 65.0 65.0 65.0 65.0 65.0 65.0
71.0 74.0 75.0 75.0 75.0 75.0 75.0 74.0
90.0 91.0 92.0 92.0 92.0 92.0 92.0 91.0
102.0 102.0 103.0 103.0 103.0 103.0 103.0 103.0
<page number="0" size="288">
<constant cols="16" digits="0" name="veTable" rows="16" units="%">
27.0 27.0 27.0 27.0 27.0 27.0 27.0 27.0 27.0 27.0 27.0 27.0 27.0 27.0 27.0 27.0
28.0 29.0 29.0 30.0 30.0 30.0 31.0 31.0 31.0 31.0 31.0 31.0 31.0 31.0 31.0 31.0
29.0 30.0 31.0 32.0 32.0 33.0 34.0 35.0 35.0 35.0 35.0 35.0 35.0 35.0 35.0 35.0
31.0 33.0 34.0 34.0 35.0 36.0 36.0 37.0 38.0 38.0 39.0 40.0 40.0 40.0 40.0 40.0
34.0 35.0 36.0 37.0 37.0 38.0 38.0 39.0 40.0 41.0 43.0 45.0 45.0 45.0 45.0 45.0
39.0 40.0 42.0 43.0 43.0 44.0 44.0 45.0 46.0 47.0 48.0 49.0 49.0 49.0 49.0 49.0
44.0 47.0 49.0 51.0 51.0 52.0 52.0 53.0 53.0 53.0 54.0 54.0 54.0 53.0 53.0 53.0
49.0 52.0 56.0 57.0 57.0 58.0 58.0 58.0 58.0 58.0 58.0 58.0 58.0 58.0 58.0 58.0
56.0 58.0 61.0 62.0 62.0 62.0 63.0 63.0 63.0 63.0 63.0 63.0 62.0 62.0 62.0 62.0
61.0 64.0 66.0 66.0 67.0 67.0 67.0 67.0 67.0 67.0 67.0 67.0 67.0 67.0 67.0 67.0
67.0 69.0 70.0 71.0 72.0 72.0 72.0 72.0 72.0 72.0 72.0 72.0 72.0 72.0 72.0 71.0
74.0 75.0 76.0 77.0 77.0 77.0 77.0 77.0 77.0 77.0 77.0 77.0 77.0 77.0 77.0 76.0
82.0 83.0 84.0 85.0 85.0 85.0 85.0 85.0 85.0 85.0 85.0 85.0 85.0 85.0 85.0 84.0
91.0 91.0 92.0 92.0 93.0 93.0 93.0 93.0 93.0 93.0 93.0 93.0 93.0 93.0 92.0 92.0
96.0 97.0 97.0 97.0 98.0 98.0 98.0 98.0 98.0 98.0 98.0 98.0 98.0 98.0 98.0 97.0
102.0 102.0 102.0 102.0 103.0 103.0 103.0 103.0 103.0 103.0 103.0 103.0 103.0 103.0 103.0 103.0
</constant>
<constant cols="1" digits="0" name="rpmBins" rows="8" units="RPM">
<constant cols="1" digits="0" name="rpmBins" rows="16" units="RPM">
1000.0
1200.0
1500.0
2000.0
3000.0
4500.0
6000.0
7500.0
1700.0
1900.0
2300.0
2800.0
3400.0
4100.0
4800.0
5500.0
6200.0
6900.0
7600.0
8300.0
9000.0
</constant>
<constant cols="1" digits="0" name="tpsBins" rows="8" units="TPS">
<constant cols="1" digits="0" name="tpsBins" rows="16" units="TPS">
2.0
4.0
6.0
10.0
25.0
45.0
65.0
85.0
8.0
9.0
15.0
22.0
30.0
40.0
49.0
58.0
68.0
77.0
86.0
93.0
100.0
</constant>
</page>
<page number="1" size="64">
<constant digits="1" name="crankCold" units="ms">6.5</constant>
<constant digits="1" name="crankHot" units="ms">3.5</constant>
<constant digits="0" name="asePct" units="%">15.0</constant>
@ -103,7 +129,7 @@
<constant name="display5">"RPM"</constant>
<constant name="displayB1">"RPM"</constant>
<constant name="displayB2">"RPM"</constant>
<constant digits="1" name="reqFuel" units="ms">12.4</constant>
<constant digits="1" name="reqFuel" units="ms">12.2</constant>
<constant digits="0" name="divider">2.0</constant>
<constant name="alternate">"Alternating"</constant>
<constant digits="1" name="injOpen" units="ms">1.0</constant>
@ -122,46 +148,72 @@
<constant name="egoType1">"Narrow band"</constant>
<constant name="algorithm">"Alpha-N"</constant>
<constant name="baroCorr">"Off"</constant>
<constant name="injTiming">"Semi-Sequential"</constant>
<constant name="injTiming">"Bank"</constant>
<constant digits="1" name="primePulse" units="ms">1.5</constant>
<constant digits="0" name="unused120" units="RPM">0.0</constant>
<constant digits="1" name="fastIdleT" units="°C">59.94</constant>
<constant digits="0" name="unused40" units="RPM">3500.0</constant>
<constant digits="0" name="unused41" units="RPM">4200.0</constant>
<constant digits="3" name="egoSwitch" units="v">0.0</constant>
<constant digits="0" name="taeColdM" units="%">0.0</constant>
<constant digits="0" name="tpsMin" units="ADC">0.0</constant>
<constant digits="0" name="tpsMax" units="ADC">252.0</constant>
</page>
<page number="1" size="128">
<constant cols="8" digits="0" name="advTable1" rows="8" units="deg">
10.0 20.0 25.0 27.0 32.0 38.0 38.0 40.0
10.0 21.0 23.0 27.0 32.0 35.0 38.0 40.0
12.0 23.0 23.0 27.0 32.0 35.0 38.0 40.0
12.0 15.0 23.0 28.0 27.0 28.0 31.0 33.0
10.0 15.0 19.0 24.0 24.0 25.0 27.0 29.0
10.0 15.0 13.0 18.0 18.0 19.0 21.0 23.0
10.0 15.0 12.0 17.0 17.0 18.0 20.0 22.0
10.0 15.0 15.0 17.0 17.0 18.0 20.0 23.0
<page number="2" size="288">
<constant cols="16" digits="0" name="advTable1" rows="16" units="deg">
10.0 15.0 19.0 22.0 24.0 26.0 27.0 28.0 31.0 33.0 36.0 38.0 38.0 38.0 39.0 40.0
10.0 15.0 20.0 22.0 24.0 25.0 26.0 28.0 31.0 33.0 35.0 37.0 37.0 38.0 39.0 40.0
10.0 15.0 20.0 22.0 23.0 24.0 26.0 28.0 31.0 33.0 34.0 36.0 37.0 38.0 39.0 40.0
11.0 16.0 21.0 22.0 23.0 24.0 26.0 28.0 31.0 33.0 34.0 35.0 37.0 38.0 39.0 40.0
12.0 17.0 22.0 23.0 23.0 24.0 26.0 28.0 31.0 33.0 34.0 35.0 37.0 38.0 39.0 40.0
12.0 16.0 20.0 21.0 23.0 24.0 26.0 28.0 30.0 31.0 32.0 33.0 34.0 36.0 37.0 38.0
12.0 14.0 16.0 19.0 22.0 25.0 27.0 28.0 28.0 28.0 29.0 30.0 31.0 33.0 33.0 34.0
11.0 13.0 15.0 18.0 21.0 24.0 26.0 27.0 26.0 26.0 27.0 28.0 29.0 30.0 31.0 32.0
11.0 13.0 15.0 17.0 19.0 22.0 24.0 25.0 25.0 25.0 25.0 26.0 27.0 28.0 29.0 30.0
10.0 12.0 15.0 16.0 17.0 19.0 22.0 23.0 23.0 23.0 23.0 24.0 25.0 26.0 27.0 28.0
10.0 12.0 15.0 15.0 15.0 17.0 19.0 20.0 20.0 20.0 21.0 21.0 22.0 23.0 24.0 25.0
10.0 12.0 15.0 14.0 13.0 15.0 17.0 18.0 18.0 18.0 19.0 19.0 20.0 21.0 22.0 23.0
10.0 12.0 15.0 14.0 13.0 14.0 16.0 17.0 17.0 18.0 18.0 19.0 20.0 21.0 21.0 22.0
10.0 12.0 15.0 14.0 13.0 14.0 16.0 17.0 17.0 17.0 18.0 18.0 19.0 20.0 21.0 22.0
10.0 12.0 15.0 14.0 14.0 15.0 16.0 17.0 17.0 17.0 18.0 18.0 19.0 20.0 21.0 23.0
10.0 12.0 15.0 15.0 15.0 16.0 17.0 17.0 17.0 17.0 18.0 18.0 19.0 20.0 22.0 23.0
</constant>
<constant cols="1" digits="0" name="rpmBins2" rows="8" units="RPM">
<constant cols="1" digits="0" name="rpmBins2" rows="16" units="RPM">
1000.0
1200.0
1500.0
2000.0
3000.0
4500.0
6000.0
7500.0
1700.0
1900.0
2300.0
2800.0
3400.0
4100.0
4800.0
5500.0
6200.0
6900.0
7600.0
8300.0
9000.0
</constant>
<constant cols="1" digits="0" name="tpsBins2" rows="8" units="TPS">
<constant cols="1" digits="0" name="tpsBins2" rows="16" units="TPS">
2.0
4.0
6.0
10.0
25.0
45.0
65.0
85.0
8.0
9.0
15.0
22.0
30.0
40.0
49.0
58.0
68.0
77.0
86.0
93.0
100.0
</constant>
</page>
<page number="3" size="64">
<constant digits="0" name="TrigAng" units="Deg">1.0</constant>
<constant digits="0" name="FixAng" units="Deg">0.0</constant>
<constant digits="0" name="CrankAng" units="Deg">11.6</constant>
@ -222,37 +274,81 @@
85.0
</constant>
</page>
<page number="2" size="128">
<constant cols="8" digits="1" name="afrTable" rows="8" units="AFR">
14.7 14.7 15.0 15.1 14.9 14.7 14.7 14.7
14.7 14.7 15.0 15.1 14.9 14.7 14.7 14.7
14.7 14.7 14.8 15.0 14.8 14.6 14.4 14.0
14.3 14.3 14.7 14.7 14.6 14.1 13.8 13.4
14.1 14.2 14.5 14.3 14.0 13.5 13.1 12.9
14.1 14.2 13.7 13.6 13.4 13.1 13.0 12.8
13.5 13.5 12.8 12.9 12.8 12.7 12.7 12.7
12.8 12.8 12.8 12.7 12.5 12.5 12.5 12.5
<page number="4" size="288">
<constant cols="16" digits="1" name="afrTable" rows="16" units="AFR">
14.7 14.7 14.7 14.8 15.0 15.0 15.1 15.0 15.0 14.9 14.8 14.7 14.7 14.7 14.7 14.7
14.7 14.7 14.7 14.8 15.0 15.0 15.1 15.0 15.0 14.9 14.8 14.7 14.7 14.7 14.7 14.7
14.7 14.7 14.7 14.8 15.0 15.0 15.1 15.0 15.0 14.9 14.8 14.7 14.7 14.7 14.7 14.7
14.7 14.7 14.7 14.8 14.9 15.0 15.0 15.0 14.9 14.8 14.7 14.6 14.6 14.6 14.5 14.4
14.7 14.7 14.7 14.8 14.8 14.9 15.0 15.0 14.9 14.8 14.7 14.6 14.5 14.4 14.3 14.1
14.6 14.6 14.6 14.6 14.7 14.8 14.9 14.9 14.8 14.7 14.5 14.4 14.3 14.2 14.0 13.8
14.4 14.4 14.4 14.5 14.7 14.7 14.8 14.7 14.7 14.6 14.3 14.2 14.0 13.9 13.7 13.5
14.2 14.3 14.3 14.4 14.6 14.6 14.6 14.6 14.5 14.3 14.1 13.9 13.7 13.6 13.4 13.3
14.2 14.2 14.2 14.4 14.5 14.5 14.4 14.3 14.2 14.1 13.8 13.6 13.4 13.3 13.2 13.0
14.1 14.1 14.2 14.3 14.3 14.3 14.2 14.1 14.0 13.8 13.6 13.4 13.2 13.1 13.0 12.9
14.1 14.1 14.2 14.1 14.0 13.9 13.9 13.8 13.7 13.5 13.4 13.2 13.1 13.0 12.9 12.8
14.0 14.1 14.1 13.9 13.7 13.6 13.5 13.5 13.4 13.3 13.1 13.0 13.0 12.9 12.9 12.8
13.7 13.8 13.8 13.5 13.2 13.2 13.2 13.1 13.1 13.0 12.9 12.9 12.8 12.8 12.8 12.7
13.5 13.5 13.5 13.2 12.9 12.8 12.9 12.9 12.8 12.8 12.7 12.7 12.7 12.7 12.7 12.7
13.1 13.1 13.1 13.0 12.8 12.8 12.8 12.8 12.7 12.6 12.6 12.6 12.6 12.6 12.6 12.6
12.8 12.8 12.8 12.8 12.8 12.8 12.7 12.6 12.6 12.5 12.5 12.5 12.5 12.5 12.5 12.5
</constant>
<constant cols="1" digits="0" name="rpmBinsAFR" rows="8" units="RPM">
<constant cols="1" digits="0" name="rpmBinsAFR" rows="16" units="RPM">
500.0
800.0
1200.0
2000.0
3000.0
3500.0
4200.0
5000.0
1500.0
1900.0
2300.0
2800.0
3100.0
3400.0
3600.0
4000.0
4300.0
4700.0
5100.0
5500.0
6000.0
</constant>
<constant cols="1" digits="0" name="tpsBinsAFR" rows="8" units="TPS">
<constant cols="1" digits="0" name="tpsBinsAFR" rows="16" units="TPS">
2.0
3.0
4.0
5.0
6.0
7.0
8.0
10.0
15.0
20.0
9.0
9.0
11.0
13.0
16.0
18.0
21.0
25.0
30.0
</constant>
</page>
<page number="5" size="64">
<constant digits="0" name="unused46" units="RPM">24300.0</constant>
<constant digits="0" name="unused47" units="RPM">24300.0</constant>
<constant digits="0" name="unused48" units="RPM">100.0</constant>
<constant digits="0" name="unused49" units="RPM">0.0</constant>
<constant digits="0" name="unused50" units="RPM">0.0</constant>
<constant digits="0" name="unused51" units="RPM">4000.0</constant>
<constant digits="0" name="unused52" units="RPM">1000.0</constant>
<constant digits="0" name="unused53" units="RPM">800.0</constant>
<constant digits="0" name="unused54" units="RPM">2300.0</constant>
<constant digits="0" name="unused55" units="RPM">6500.0</constant>
<constant digits="0" name="unused56" units="RPM">3200.0</constant>
<constant digits="0" name="unused57" units="RPM">3500.0</constant>
<constant digits="0" name="unused58" units="RPM">3800.0</constant>
<constant digits="0" name="unused59" units="RPM">100.0</constant>
<constant digits="0" name="unused60" units="RPM">24300.0</constant>
<constant digits="0" name="unused61" units="RPM">4500.0</constant>
<constant digits="0" name="unused62" units="RPM">3000.0</constant>
<constant digits="0" name="unused63" units="RPM">6000.0</constant>
<constant name="egoAlgorithm">"No correction"</constant>
<constant name="egoType">"Wide Band"</constant>
<constant digits="0" name="egoKP" units="%">100.0</constant>
@ -282,8 +378,8 @@
151.0
107.0
100.0
95.0
89.0
100.0
100.0
</constant>
<constant cols="1" digits="0" name="airDenBins" rows="9" units="C">
-40.0
@ -307,6 +403,81 @@
81.0
74.0
</constant>
<constant digits="0" name="unused45" units="RPM">24300.0</constant>
</page>
<page number="6" size="64">
<constant cols="1" digits="0" name="iacCLValues" rows="10" units="RPM">
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
</constant>
<constant cols="1" digits="0" name="iacOLStepVal" rows="10" units="Steps">
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
</constant>
<constant cols="1" digits="0" name="iacOLPWMVal" rows="10" units="Duty %">
0.0
7.0
11.0
16.0
19.0
24.0
29.0
34.0
38.0
43.0
</constant>
<constant cols="1" digits="0" name="iacBins" rows="10" units="C">
108.0
81.0
52.0
28.0
14.0
1.0
-12.0
-21.0
-31.0
-37.0
</constant>
<constant cols="1" digits="0" name="iacCrankSteps" rows="4" units="Steps">
0.0
0.0
0.0
0.0
</constant>
<constant cols="1" digits="0" name="iacCrankDuty" rows="4" units="Duty %">
27.0
33.0
42.0
59.0
</constant>
<constant cols="1" digits="0" name="iacCrankBins" rows="4" units="C">
127.0
80.0
39.0
-13.0
</constant>
<constant name="iacAlgorithm">"None"</constant>
<constant name="iacStepTime">"1"</constant>
<constant name="unused38">0</constant>
<constant digits="0" name="iacFastTemp" units="C">-40.0</constant>
<constant digits="0" name="iacStepHome" units="Steps">0.0</constant>
<constant digits="1" name="iacStepHyster" units="C">0.0</constant>
</page>
<settings Comment="These setting are only used if this msq is opened without a project.">
<setting name="CELSIUS" value="CELSIUS"/>

View File

@ -1071,9 +1071,11 @@ help = helpEnrichments, "Enrichments Help"
throttle = { tps }, "%"
altDiv = { alternate ? 2 : 1 }
cycleTime = { 60000.0 / rpm * (2.0-twoStroke) }
;cycleTime = { 60000.0 / rpm * (2.0-twoStroke) }
cycleTime = { 60000.0 / rpm }
nSquirts = { nCylinders/divider }
dutyCycle = { 100.0*nSquirts/altDiv*pulseWidth/cycleTime }
;dutyCycle = { 100.0*nSquirts/altDiv*pulseWidth/cycleTime }
dutyCycle = { 100.0*pulseWidth/cycleTime }
#if EXPANDED_CLT_TEMP
clt_exp = { 1 }

View File

@ -185,7 +185,7 @@ void setIgnitionSchedule4(void (*startCallback)(), unsigned long timeout, unsign
//This calls the relevant callback function (startCallback or endCallback) depending on the status of the schedule.
//If the startCallback function is called, we put the scheduler into RUNNING state
//Timer3A (fuel schedule 1) Compare Vector
ISR(TIMER3_COMPA_vect) //fuelSchedule1
ISR(TIMER3_COMPA_vect, ISR_NOBLOCK) //fuelSchedule1
{
if (fuelSchedule1.Status == PENDING) //Check to see if this schedule is turn on
{
@ -202,7 +202,7 @@ ISR(TIMER3_COMPA_vect) //fuelSchedule1
TIMSK3 &= ~(1 << OCIE3A); //Turn off this output compare unit (This simply writes 0 to the OCIE3A bit of TIMSK3)
}
}
ISR(TIMER3_COMPB_vect) //fuelSchedule2
ISR(TIMER3_COMPB_vect, ISR_NOBLOCK) //fuelSchedule2
{
if (fuelSchedule2.Status == PENDING) //Check to see if this schedule is turn on
{
@ -219,9 +219,8 @@ ISR(TIMER3_COMPB_vect) //fuelSchedule2
TIMSK3 &= ~(1 << OCIE3B); //Turn off this output compare unit (This simply writes 0 to the OCIE3A bit of TIMSK3)
}
}
ISR(TIMER3_COMPC_vect) //fuelSchedule3
ISR(TIMER3_COMPC_vect, ISR_NOBLOCK) //fuelSchedule3
{
noInterrupts();
if (fuelSchedule3.Status == PENDING) //Check to see if this schedule is turn on
{
fuelSchedule3.StartCallback();
@ -236,11 +235,9 @@ ISR(TIMER3_COMPC_vect) //fuelSchedule3
fuelSchedule3.Status = OFF; //Turn off the schedule
TIMSK3 &= ~(1 << OCIE3C); //Turn off this output compare unit (This simply writes 0 to the OCIE3A bit of TIMSK3)
}
interrupts();
}
ISR(TIMER4_COMPB_vect) //fuelSchedule4
ISR(TIMER4_COMPB_vect, ISR_NOBLOCK) //fuelSchedule4
{
noInterrupts();
if (fuelSchedule4.Status == PENDING) //Check to see if this schedule is turn on
{
fuelSchedule4.StartCallback();
@ -255,9 +252,8 @@ ISR(TIMER4_COMPB_vect) //fuelSchedule4
fuelSchedule4.Status = OFF; //Turn off the schedule
TIMSK4 &= ~(1 << OCIE4B); //Turn off this output compare unit (This simply writes 0 to the OCIE3A bit of TIMSK3)
}
interrupts();
}
ISR(TIMER5_COMPA_vect) //ignitionSchedule1
ISR(TIMER5_COMPA_vect, ISR_NOBLOCK) //ignitionSchedule1
{
if (ignitionSchedule1.Status == PENDING) //Check to see if this schedule is turn on
{
@ -276,7 +272,7 @@ ISR(TIMER5_COMPA_vect) //ignitionSchedule1
TIMSK5 &= ~(1 << OCIE5A); //Turn off this output compare unit (This simply writes 0 to the OCIE3A bit of TIMSK3)
}
}
ISR(TIMER5_COMPB_vect) //ignitionSchedule2
ISR(TIMER5_COMPB_vect, ISR_NOBLOCK) //ignitionSchedule2
{
if (ignitionSchedule2.Status == PENDING) //Check to see if this schedule is turn on
{
@ -295,9 +291,8 @@ ISR(TIMER5_COMPB_vect) //ignitionSchedule2
TIMSK5 &= ~(1 << OCIE5B); //Turn off this output compare unit (This simply writes 0 to the OCIE3A bit of TIMSK3)
}
}
ISR(TIMER5_COMPC_vect) //ignitionSchedule3
ISR(TIMER5_COMPC_vect, ISR_NOBLOCK) //ignitionSchedule3
{
noInterrupts();
if (ignitionSchedule3.Status == PENDING) //Check to see if this schedule is turn on
{
ignitionSchedule3.Status = RUNNING; //Set the status to be in progress (ie The start callback has been called, but not the end callback)
@ -314,11 +309,9 @@ ISR(TIMER5_COMPC_vect) //ignitionSchedule3
ignitionCount += 1; //Increment the igintion counter
TIMSK5 &= ~(1 << OCIE5C); //Turn off this output compare unit (This simply writes 0 to the OCIE3A bit of TIMSK3)
}
interrupts();
}
ISR(TIMER4_COMPA_vect) //ignitionSchedule4
ISR(TIMER4_COMPA_vect, ISR_NOBLOCK) //ignitionSchedule4
{
noInterrupts();
if (ignitionSchedule4.Status == PENDING) //Check to see if this schedule is turn on
{
ignitionSchedule4.Status = RUNNING; //Set the status to be in progress (ie The start callback has been called, but not the end callback)
@ -335,5 +328,4 @@ ISR(TIMER4_COMPA_vect) //ignitionSchedule4
ignitionCount += 1; //Increment the igintion counter
TIMSK5 &= ~(1 << OCIE4A); //Turn off this output compare unit (This simply writes 0 to the OCIE3A bit of TIMSK3)
}
interrupts();
}

View File

@ -425,9 +425,6 @@ void loop()
//How fast are we going? Need to know how long (uS) it will take to get from one tooth to the next. We then use that to estimate how far we are between the last tooth and the next one
timePerDegree = ldiv( 166666L, currentStatus.RPM ).quot; //There is a small amount of rounding in this calculation, however it is less than 0.001 of a uS (Faster as ldiv than / )
//Determine the current crank angle
int crankAngle = getCrankAngle(timePerDegree);
//***********************************************************************************************
//BEGIN INJECTION TIMING
//Determine next firing angles
@ -542,6 +539,10 @@ void loop()
//Finally calculate the time (uS) until we reach the firing angles and set the schedules
//We only need to set the shcedule if we're BEFORE the open angle
//This may potentially be called a number of times as we get closer and closer to the opening time
//Determine the current crank angle
int crankAngle = getCrankAngle(timePerDegree);
if (injector1StartAngle > crankAngle)
{
if (configPage1.injTiming == 1)

View File

@ -29,7 +29,7 @@ void initialiseTimers()
//Timer2 Overflow Interrupt Vector, called when the timer overflows.
//Executes every ~1ms.
ISR(TIMER2_OVF_vect)
ISR(TIMER2_OVF_vect, ISR_NOBLOCK)
{
//Increment Loop Counters