diff --git a/firmware/controllers/system/pwm_generator_logic.cpp b/firmware/controllers/system/pwm_generator_logic.cpp index 4931938ee1..c11c8009f0 100644 --- a/firmware/controllers/system/pwm_generator_logic.cpp +++ b/firmware/controllers/system/pwm_generator_logic.cpp @@ -139,10 +139,9 @@ efitimeus_t PwmConfig::togglePwmState() { if (cisnan(periodNt)) { /** - * NaN period means PWM is paused - * TODO: what about pin state? low, high or random? - * TODO: cover this with a unit test + * NaN period means PWM is paused, we also set the pin low */ + stateChangeCallback(this, 0); return getTimeNowUs() + MS2US(NAN_FREQUENCY_SLEEP_PERIOD_MS); } if (mode != PM_NORMAL) { diff --git a/unit_tests/test_pwm_generator.cpp b/unit_tests/test_pwm_generator.cpp index c04837d98c..08b4486f3e 100644 --- a/unit_tests/test_pwm_generator.cpp +++ b/unit_tests/test_pwm_generator.cpp @@ -91,11 +91,11 @@ static void testSwitchToNanPeriod() { expectedTimeOfNextEvent += 600; assertEqualsM2("1@1000/NAN", expectedTimeOfNextEvent, schedulingQueue.getForUnitText(0)->momentX, 0); - assertNextEvent("exec2@70", 1); + assertNextEvent("exec2@NAN", 0); expectedTimeOfNextEvent += MS2US(NAN_FREQUENCY_SLEEP_PERIOD_MS); assertEqualsM2("2@1000/NAN", expectedTimeOfNextEvent, schedulingQueue.getForUnitText(0)->momentX, 0); - assertNextEvent("exec3@NAN", 1); + assertNextEvent("exec3@NAN", 0); } void testPwmGenerator() {