Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LEDC on ESP32-S2 frequency calculation #5375

Closed
simon-jouet opened this issue Jul 11, 2021 · 0 comments · Fixed by #5452
Closed

LEDC on ESP32-S2 frequency calculation #5375

simon-jouet opened this issue Jul 11, 2021 · 0 comments · Fixed by #5452
Assignees
Labels
Chip: ESP32-S2 Issue is related to support of ESP32-S2 Chip

Comments

@simon-jouet
Copy link

simon-jouet commented Jul 11, 2021

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() {
}
@me-no-dev me-no-dev added this to Seeking Contributors in (Archived) Arduino Core ESP32 RoadMap Jul 12, 2021
@VojtechBartoska VojtechBartoska added the Chip: ESP32-S2 Issue is related to support of ESP32-S2 Chip label Jul 14, 2021
@VojtechBartoska VojtechBartoska modified the milestone: 2.0.0 Jul 14, 2021
@VojtechBartoska VojtechBartoska added the Status: Test needed Issue needs testing label Jul 14, 2021
@VojtechBartoska VojtechBartoska moved this from To-Do (Seeking Contributors) to Test Needed in (Archived) Arduino Core ESP32 RoadMap Jul 20, 2021
@VojtechBartoska VojtechBartoska added this to the 2.0.1 milestone Jul 22, 2021
@VojtechBartoska VojtechBartoska removed this from the 2.0.1 milestone Jul 22, 2021
me-no-dev pushed a commit that referenced this issue Jul 26, 2021
@SuGlider SuGlider moved this from Test Needed to 2.0.0 release in (Archived) Arduino Core ESP32 RoadMap Jul 26, 2021
@SuGlider SuGlider moved this from 2.0.0 release to Development Complete in (Archived) Arduino Core ESP32 RoadMap Jul 26, 2021
@VojtechBartoska VojtechBartoska removed the Status: Test needed Issue needs testing label Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Chip: ESP32-S2 Issue is related to support of ESP32-S2 Chip
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

3 participants