I'm trying to generate a 20 kHz signal PWM signal. I'm a bit confused with esp's ledc api. I read the documentation and found that the lower my timer bit and the higher the base frequency I can achieve and also the APB clock of the esp generates upto 80 MHz signal. After read thing this post on ESP's forum, and trying to implement that I still could not get a 20 kHz frequency signal.
Here is a basic sketch that I've been playing with
#define LEDC_CHANNEL_0 0
#define LEDC_TIMER_BIT 1
#define LEDC_BASE_FREQ 20000
#define LED_PIN 33
void setup() {
ledcSetup(LEDC_CHANNEL_0, LEDC_BASE_FREQ, LEDC_TIMER_BIT);
ledcAttachPin(LED_PIN, LEDC_CHANNEL_0);
ledcWrite(LEDC_CHANNEL_0, 255); // ((2 * TIMER_BIT) - 1) * x%
}
void loop() {
}
Basically the motor that I'm trying to control creates audible noise and I'm trying to reduce that, my initial thinking was if I get above or at 20 kHz that would reduce the noise at least to some extent.
Thanks.