diff --git a/ports/esp32/modmachine.c b/ports/esp32/modmachine.c index db77becf87..a70f2fbedb 100644 --- a/ports/esp32/modmachine.c +++ b/ports/esp32/modmachine.c @@ -82,8 +82,16 @@ STATIC mp_obj_t machine_freq(size_t n_args, const mp_obj_t *args) { } else { // set mp_int_t freq = mp_obj_get_int(args[0]) / 1000000; - if (freq != 20 && freq != 40 && freq != 80 && freq != 160 && freq != 240) { + if (freq != 20 && freq != 40 && freq != 80 && freq != 160 + #if !CONFIG_IDF_TARGET_ESP32C3 + && freq != 240 + #endif + ) { + #if CONFIG_IDF_TARGET_ESP32C3 + mp_raise_ValueError(MP_ERROR_TEXT("frequency must be 20MHz, 40MHz, 80Mhz or 160MHz")); + #else mp_raise_ValueError(MP_ERROR_TEXT("frequency must be 20MHz, 40MHz, 80Mhz, 160MHz or 240MHz")); + #endif } #if CONFIG_IDF_TARGET_ESP32 esp_pm_config_esp32_t pm;