Enable higher PWM frequencies for ESP32

LEDC peripheral of ESP32 allows higher PWM frequencies than the ESP8266.

Higher frequencies come with reduced available bit depth (as by https://esphome.io/components/output/ledc.html).

New max value of 50 kHz to include at least the frequency for 4-pin pwm fans and a bit more.
This commit is contained in:
Thomas A 2021-02-08 18:52:03 +01:00
parent 4926222dd7
commit 0707a9648b
1 changed files with 4 additions and 0 deletions

View File

@ -126,7 +126,11 @@ const uint32_t PWM_RANGE = 1023; // 255..1023 needs to be devisible b
//const uint16_t PWM_FREQ = 1000; // 100..1000 Hz led refresh
//const uint16_t PWM_FREQ = 910; // 100..1000 Hz led refresh (iTead value)
const uint16_t PWM_FREQ = 977; // 100..4000 Hz led refresh
#ifdef ESP32
const uint16_t PWM_MAX = 50000; // [PWM_MAX] Maximum frequency for ESP32 - Default: 4000
#else
const uint16_t PWM_MAX = 4000; // [PWM_MAX] Maximum frequency - Default: 4000
#endif
const uint16_t PWM_MIN = 40; // [PWM_MIN] Minimum frequency - Default: 40
// For Dimmers use double of your mains AC frequecy (100 for 50Hz and 120 for 60Hz)
// For Controlling Servos use 50 and also set PWM_FREQ as 50 (DO NOT USE THESE VALUES FOR DIMMERS)