diff --git a/Sming/Arch/Esp32/Core/HardwarePWM.cpp b/Sming/Arch/Esp32/Core/HardwarePWM.cpp index 9a58e5aad1..d8a7a91986 100644 --- a/Sming/Arch/Esp32/Core/HardwarePWM.cpp +++ b/Sming/Arch/Esp32/Core/HardwarePWM.cpp @@ -140,11 +140,8 @@ uint32_t maxDuty(ledc_timer_bit_t bits) HardwarePWM::HardwarePWM(uint8_t* pins, uint8_t no_of_pins) : channel_count(no_of_pins) { - assert(no_of_pins <= SOC_LEDC_CHANNEL_NUM); - - if(no_of_pins == 0) { - return; - } + assert(no_of_pins > 0 && no_of_pins <= SOC_LEDC_CHANNEL_NUM); + no_of_pins = std::min(uint8_t(SOC_LEDC_CHANNEL_NUM), no_of_pins); periph_module_enable(PERIPH_LEDC_MODULE);