Something else that caught my eye is that in cases where it produced the intended result, e.g. 1000Hz, I could still observe some irregularities in the wave pattern, for example the duty cycle shifting to about 67% for a short period of time. I can easily see this as just being a shortcoming of the hardware, but I thought I'd still mention it...
Here's the code:
Code: Select all
extern "C" void app_main(void)
{
gpio_set_direction(MCLK_PIN, GPIO_MODE_OUTPUT);
ledc_timer_config_t timer_cfg = {
.speed_mode = LEDC_HIGH_SPEED_MODE,
.duty_resolution = LEDC_TIMER_1_BIT,
.timer_num = LEDC_TIMER_0,
.freq_hz = 24000000,
.clk_cfg = LEDC_USE_APB_CLK
};
ESP_ERROR_CHECK(ledc_timer_config(&timer_cfg));
ledc_channel_config_t chan_cfg = {
.gpio_num = MCLK_PIN,
.speed_mode = LEDC_HIGH_SPEED_MODE,
.channel = LEDC_CHANNEL_0,
.intr_type = LEDC_INTR_DISABLE,
.timer_sel = LEDC_TIMER_0,
.duty = 1,
.hpoint = 0,
.sleep_mode = LEDC_SLEEP_MODE_NO_ALIVE_NO_PD
};
ESP_ERROR_CHECK(ledc_channel_config(&chan_cfg));
while (true) {
vTaskDelay(pdMS_TO_TICKS(10));
}
}SDKCONFIG: https://pastebin.com/HE0FsgZ3
I'm new to esp32 development so I might've missed something obvious
