From 01295e8590165ed7e81185c7f56d3e277a68b920 Mon Sep 17 00:00:00 2001 From: rusefi Date: Fri, 11 Aug 2017 14:02:15 -0400 Subject: [PATCH] fix #472 --- firmware/controllers/trigger/trigger_central.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 831d298031..bd28514f4e 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -98,6 +98,13 @@ void hwHandleVvtCamSignal(trigger_value_e front) { return; } + floatus_t oneDegreeUs = engine->rpmCalculator.oneDegreeUs; + if (cisnan(oneDegreeUs)) { + // we are here if we are getting VVT position signals while engine is not running + // for example if crank position sensor is broken :) + return; + } + TriggerCentral *tc = &engine->triggerCentral; efitick_t nowNt = getTimeNowNt(); @@ -124,7 +131,7 @@ void hwHandleVvtCamSignal(trigger_value_e front) { efitick_t offsetNt = nowNt - tc->timeAtVirtualZeroNt; - angle_t vvtPosition = NT2US(offsetNt) / engine->rpmCalculator.oneDegreeUs; + angle_t vvtPosition = NT2US(offsetNt) / oneDegreeUs; // convert engine cycle angle into trigger cycle angle vvtPosition -= tdcPosition();