Skip to content

ESP32-ESP32S2-AnalogWrite 1.2.0

Compare
Choose a tag to compare
@Dlloydev Dlloydev released this 21 Apr 00:50
· 76 commits to main since this release

Arduino's reference for analogWrite() describes the PWM wave characteristics for various hardware architecture. The general operational characteristic is 8-bit duty cycle control where the output will be always off for value 0 and always on for value 255. With the various devices and timer modes, sometimes a bit correction is required to achieve full off or on. The ESP8266 follows this mode of operation, but with the different timer architecture on the ESP32 devices, the LEDc PWM operates in a different manner, where duty value 0 is always off, but duty value 255 will give an output that's 255/256 duty cycle (not fully on). This happens for any setting for bit resolution. As of this version 1.2.0, this condition is detected and corrected, where the hardware is programmed with 2^resolution (bits)^, which drives the output signal fully on.