Add protection for possible interrupt clash on 4g63 (Rare issue)

This commit is contained in:
Josh Stewart 2015-12-06 17:28:40 +11:00
parent 7d32be4317
commit 756b048e5a
1 changed files with 7 additions and 5 deletions

View File

@ -451,11 +451,13 @@ int getRPM_4G63()
//Because these signals aren't even (Alternativing 110 and 70 degrees), this needs a special function //Because these signals aren't even (Alternativing 110 and 70 degrees), this needs a special function
if(currentStatus.RPM < configPage2.crankRPM) if(currentStatus.RPM < configPage2.crankRPM)
{ {
noInterrupts(); int tempToothAngle;
revolutionTime = (toothLastToothTime - toothLastMinusOneToothTime); //Note that trigger tooth angle changes between 70 and 110 depending on the last tooth that was seen noInterrupts();
interrupts(); tempToothAngle = triggerToothAngle;
revolutionTime = revolutionTime * 36; revolutionTime = (toothLastToothTime - toothLastMinusOneToothTime); //Note that trigger tooth angle changes between 70 and 110 depending on the last tooth that was seen
return (triggerToothAngle * 60000000L) / revolutionTime; interrupts();
revolutionTime = revolutionTime * 36;
return (tempToothAngle * 60000000L) / revolutionTime;
} }
else { return stdGetRPM(); } else { return stdGetRPM(); }
} }