[LEDC-3.12] When the LEDC Is in Decremental Fade Mode, a Duty Overflow Error May Occur

Affected revisions: v0.0 v1.0 v1.1 v3.0 v3.1

Description

This issue may happen when the LEDC is in decremental fade mode and LEDC_DUTY_SCALE_HSCHn is 1. If the duty is 2LEDC_HSTIMERx_DUTY_RES, then the next one should be 2LEDC_HSTIMERx_DUTY_RES – 1, however, the next duty is actually 2LEDC_HSTIMERx_DUTY_RES+1, which indicates a duty overflow error. (HSCHn refers to high-speed channel with n being 0-7; HSTIMERx refers to high-speed timer with x being 0-3.)

For low-speed channels, the same issue may also happen.

Workarounds

When using LEDC, avoid the concurrence of following three cases:

  1. The LEDC is in decremental fade mode;

  2. The scale register is set to 1;

  3. The duty is 2LEDC_HSTIMERx_DUTY_RES or 2LEDC_LSTIMERx_DUTY_RES.

Solution

This issue is automatically worked around in the LEDC driver since the ESP-IDF commit ID b2e264e and is released in ESP-IDF v3.1.