From 756b048e5aaeb2a7304b83ba2381315283cd1f7c Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Sun, 6 Dec 2015 17:28:40 +1100 Subject: [PATCH] Add protection for possible interrupt clash on 4g63 (Rare issue) --- decoders.ino | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/decoders.ino b/decoders.ino index f6edce5..458bc1d 100644 --- a/decoders.ino +++ b/decoders.ino @@ -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(); } }