alunit3 / ServoESP32

fixed version of servoesp32
MIT License
3 stars 0 forks source link

Timer resolution on ESP32 S3 #3

Open Mark0ne opened 3 months ago

Mark0ne commented 3 months ago

Hello. I've had a problem when using ESP32 S3. This library calls for a timer resolution of 16 bits, but ledc_caps.h only provides 14 bits.

Line 62 in Servo.h

static const int TIMER_RESOLUTION = 16;

Line 142 in Servo.h, attach().

ledcSetup(_channel, frequency, TIMER_RESOLUTION);

Line 59 in esp32-hal-led.c, ledcSetup(). TIMER_RESOLUTION is passed for argument bit-num.

if(chan >= LEDC_CHANNELS || bit_num > LEDC_MAX_BIT_WIDTH){
        log_e("No more LEDC channels available! (maximum %u) or bit width too big (maximum %u)", LEDC_CHANNELS, LEDC_MAX_BIT_WIDTH);
        return 0;
    }

Line 33 in esp32-hal-led.c

#define LEDC_MAX_BIT_WIDTH      SOC_LEDC_TIMER_BIT_WIDE_NUM

Line 17 in ledc_caps.h

#define SOC_LEDC_TIMER_BIT_WIDE_NUM  (14)