ESP32S2 Maximum GPIO Frequency

I got my ESP32S2 and trying to verify the Maximim GPIO Toggle Frequency. The logic analyser measures upto 250Hz. Shouldn't it be 40MHz?

This is the code I used to test:

int freq = 5000;
int ledChannel = 0;
int resolution = 8;

void setup() {
ledcSetup(ledChannel, freq, resolution);
ledcAttachPin(LED_BUILTIN, ledChannel);
}

void loop() {
for(int dutyCycle = 0; dutyCycle <= 255; dutyCycle++) {
ledcWrite(ledChannel, dutyCycle);
delay(7);
}

for(int dutyCycle = 255; dutyCycle >= 0; dutyCycle--) {
ledcWrite(ledChannel, dutyCycle);
delay(7);
}
}

Can someone please tell me where am I going wrong?

40 MHz is achieved only with duty resolution of 1 bit. This means that the duty cycle is fixed at 50% and cannot be adjusted.

see the documentation

1 Like

The ESP32 ABP clk is 80Mhz. The 80Mhz will be a factor in the GPIO speed limit.

1 Like

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.