adafruit / circuitpython

CircuitPython - a Python implementation for teaching coding with microcontrollers
https://circuitpython.org
MIT License
3.95k stars 1.16k forks source link

Settable microcontroller.cpu.frequency on espressif builds #9305

Open Sola85 opened 3 weeks ago

Sola85 commented 3 weeks ago

Currently only "RP2040 boards and some i.MX boards" support changing the CPU frequency. In particular, none of the esp32 boards do, despite the hardware being capable of this in principle.

Is this not implemented simply due to lack of significance, or was there a deliberate decision against this? (E.g. was this tried and determined to result in unstable USB/Peripherals/... ?)

Looking through previous discussions on this topic (e.g. https://github.com/adafruit/circuitpython/issues/2284, https://github.com/adafruit/circuitpython/issues/4176, https://github.com/adafruit/circuitpython/issues/4339 and https://github.com/adafruit/circuitpython/pull/6279), I find no indication of this being attempted for esp32 builds, which makes me guess that simply no one got around to implementing this.

A possible implementation could follow that of micropython here, or the Arduino ESP32 core here. Would a PR implementing either of the two options have a chance of being accepted?

tannewt commented 3 weeks ago

Yup! We'd totally accept it. We just haven't had anyone implement it.

dhalbert commented 3 weeks ago

Any precomputed values or peripheral settings that depend on the current clock rate would need to be changed, unless we specifically said "that's your problem".

tannewt commented 3 weeks ago

We do warn in the docs already: image