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

Added Support for ESP32-C3 #25

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Servo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ bool Servo::attach(int pin, int channel,
_minPulseWidth = minPulseWidth;
_maxPulseWidth = maxPulseWidth;

ledcSetup(_channel, 50, 16); // channel X, 50 Hz, 16-bit depth
#ifdef CONFIG_IDF_TARGET_ESP32C3
// the ESP32-C3 can not use 50Hz
ledcSetup(_channel, 200, std::min(16, SOC_LEDC_TIMER_BIT_WIDE_NUM)); // channel X, 200 Hz, 16-bit depth or chip max
#else
// all other ESP32
ledcSetup(_channel, 50, std::min(16, SOC_LEDC_TIMER_BIT_WIDE_NUM)); // channel X, 50 Hz, 16-bit depth or chip max
#endif

ledcAttachPin(_pin, _channel);
return true;
}
Expand Down