Skip to content

LEDC on ESP32-S2 frequency calculation #5375

Closed
@simon-jouet

Description

@simon-jouet

Hardware:

Board: es32-s2 wrover
Core Installation version: 2.0.0 alpha 21947eb
IDE name: platform.io
Flash Frequency: 40Mhz
PSRAM enabled: no
Upload Speed: 460800
Computer OS: Xubuntu

Description:

The frequency of the ledc driver when running on an esp32-s2 is off by a factor of 80. If you configure to have a fairly slow frequency (50Hz in my case) the ledc output frequency will be 0.62

image

My guess is that the culprit is https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-ledc.c#L154, the ESP32-S2 doesn't have a high speed mode for ledc.

If i multiply the clock by 80 then I get the desired frequency

image

Sketch

#include <Arduino.h>
#include "driver/ledc.h"

void setup() {
  ledcSetup(LEDC_CHANNEL_7, 50, LEDC_TIMER_14_BIT);
  ledcAttachPin(38, LEDC_CHANNEL_7);
  ledcWrite(LEDC_CHANNEL_7, 8191);
}

void loop() {
}

Metadata

Metadata

Assignees

Labels

Chip: ESP32-S2Issue is related to support of ESP32-S2 Chip

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions