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
if(currentStatus.RPM < configPage2.crankRPM)
{
noInterrupts();
revolutionTime = (toothLastToothTime - toothLastMinusOneToothTime); //Note that trigger tooth angle changes between 70 and 110 depending on the last tooth that was seen
interrupts();
revolutionTime = revolutionTime * 36;
return (triggerToothAngle * 60000000L) / revolutionTime;
int tempToothAngle;
noInterrupts();
tempToothAngle = triggerToothAngle;
revolutionTime = (toothLastToothTime - toothLastMinusOneToothTime); //Note that trigger tooth angle changes between 70 and 110 depending on the last tooth that was seen
interrupts();
revolutionTime = revolutionTime * 36;
return (tempToothAngle * 60000000L) / revolutionTime;
}
else { return stdGetRPM(); }
}