diff --git a/firmware/config/engines/honda_accord.cpp b/firmware/config/engines/honda_accord.cpp index 604a57259a..5d97ba67c3 100644 --- a/firmware/config/engines/honda_accord.cpp +++ b/firmware/config/engines/honda_accord.cpp @@ -29,6 +29,8 @@ void setFrankenso_01_LCD(board_configuration_s *boardConfiguration) { static void setHondaAccordConfigurationCommon(engine_configuration_s *engineConfiguration, board_configuration_s *boardConfiguration) { engineConfiguration->map.sensor.sensorType = MT_DENSO183; + boardConfiguration->isFastAdcEnabled = true; + engineConfiguration->ignitionMode = IM_ONE_COIL; engineConfiguration->injectionMode = IM_BATCH; diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 1df7521ed7..9f791bbdc9 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -156,11 +156,11 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_ // set_cranking_fuel_max 6 40 engineConfiguration->crankingSettings.coolantTempMaxC = 40; // 6ms at 40C - engineConfiguration->crankingSettings.fuelAtMaxTempMs = 6; + engineConfiguration->crankingSettings.fuelAtMaxTempMs = 24; // set_cranking_fuel_min 6 -40 engineConfiguration->crankingSettings.coolantTempMinC = -40; // 6ms at -40C - engineConfiguration->crankingSettings.fuelAtMinTempMs = 6; + engineConfiguration->crankingSettings.fuelAtMinTempMs = 24; engineConfiguration->analogInputDividerCoefficient = 2; @@ -229,6 +229,7 @@ void setDefaultConfiguration(engine_configuration_s *engineConfiguration, board_ engineConfiguration->globalFuelCorrection = 1; + boardConfiguration->isFastAdcEnabled = false; engineConfiguration->map.sensor.sensorType = MT_MPX4250; engineConfiguration->baroSensor.sensorType = MT_CUSTOM; diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index bb81e226b8..785b8c6056 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -142,7 +142,11 @@ static void fanRelayControl(void) { Overflow64Counter halTime; uint64_t getTimeNowUs(void) { - return halTime.get(hal_lld_get_counter_value(), false) / (CORE_CLOCK / 1000000); + return getTimeNowNt() / (CORE_CLOCK / 1000000); +} + +uint64_t getTimeNowNt(void) { + return halTime.get(hal_lld_get_counter_value(), false); } //uint64_t getHalTimer(void) { diff --git a/firmware/controllers/math/efitime.h b/firmware/controllers/math/efitime.h index d39a9aa34c..386bb84607 100644 --- a/firmware/controllers/math/efitime.h +++ b/firmware/controllers/math/efitime.h @@ -37,11 +37,16 @@ extern "C" /** * 64-bit counter of microseconds (1/1 000 000 of a second) since MCU reset * - * By using 64 bit, we can achive a very precise timestamp which does not overflow. + * By using 64 bit, we can achieve a very precise timestamp which does not overflow. * The primary implementation counts the number of CPU cycles from MCU reset. */ uint64_t getTimeNowUs(void); +/** + * 64-bit counter CPU cycles since MCU reset + */ +uint64_t getTimeNowNt(void); + uint64_t getHalTimer(void); /** diff --git a/firmware/controllers/system/pwm_generator_logic.cpp b/firmware/controllers/system/pwm_generator_logic.cpp index f7c5b78fb5..2c08e300d6 100644 --- a/firmware/controllers/system/pwm_generator_logic.cpp +++ b/firmware/controllers/system/pwm_generator_logic.cpp @@ -61,7 +61,7 @@ static uint64_t getNextSwitchTimeUs(PwmConfig *state) { #if DEBUG_PWM scheduleMsg(&logger, "start=%d timeToSwitch=%d", state->safe.start, timeToSwitch); #endif - return state->safe.startUs + timeToSwitchUs; + return NT2US(state->safe.startNt) + timeToSwitchUs; } void PwmConfig::handleCycleStart() { @@ -74,7 +74,7 @@ void PwmConfig::handleCycleStart() { /** * period length has changed - we need to reset internal state */ - safe.startUs = getTimeNowUs(); + safe.startNt = getTimeNowNt(); safe.iteration = 0; safe.periodUs = periodUs; #if DEBUG_PWM diff --git a/firmware/controllers/system/pwm_generator_logic.h b/firmware/controllers/system/pwm_generator_logic.h index 7c8076509f..0c988401a0 100644 --- a/firmware/controllers/system/pwm_generator_logic.h +++ b/firmware/controllers/system/pwm_generator_logic.h @@ -26,7 +26,7 @@ typedef struct { /** * Start time of current iteration */ - uint64_t startUs; + uint64_t startNt; int phaseIndex; } pwm_config_safe_state_s; diff --git a/firmware/iar/ch.ewd b/firmware/iar/ch.ewd index 6bbf58f7ac..c01694ea3e 100644 --- a/firmware/iar/ch.ewd +++ b/firmware/iar/ch.ewd @@ -45,7 +45,7 @@