Page 1 of 1

Changing the CPU frequency on ESP32

Posted: Mon May 07, 2018 10:46 am
by ZKDMun
Hi there,
I have a little problem with changing the CPU frequency on ESP32.

On ESP8266, you can do this:

Code: Select all

>>> import machine
>>> machine.freq()
80000000
>>> machine.freq(160000000)
>>> machine.freq()
160000000
See here.

But on my ESP32, I will get this result:

Code: Select all

>>> import machine
>>> machine.freq()
240000000
>>> machine.freq(160000000) 
>>> machine.freq()
240000000
80MHz, 160MHz and 240MHz should be possible (right?) - but why I can not change it via machine.freq([frequence]) on ESP32

On ESP32 MicroPython v1.9.3-548-gcd12483d9-2018-04-19 is installed.

Re: Changing the CPU frequency on ESP32

Posted: Mon May 07, 2018 10:52 am
by OutoftheBOTS_
not sure but my understanding is that it has to be a divider of the full spped of the clock, 240MHz for ESP32 and a divider of 160MHz for the ESP8266.

Speeds used on ESP8266 is 80Mhz and 160Mhz
Speeds used on ESP32 is 120MHz and 240Mhz

Re: Changing the CPU frequency on ESP32

Posted: Mon May 07, 2018 11:03 am
by ZKDMun
ESP32-datasheet:
Max-Speed: 240MHz
Normal-Speed: 80MHz
see here (page 21).

Code: Select all

>>> machine.freq(120000000)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: frequency can only be either 80Mhz, 160MHz or 240MHz
So, 80MHz, 160MHz or 240MHz should be possible with MicroPython (with 120MHz you will get this ValueError)?

(Default is at Max-Speed 240MHz - on the ESP8266 the Max-Speed is 160MHz, but the default is on 80MHz)

Re: Changing the CPU frequency on ESP32

Posted: Sat Feb 02, 2019 6:11 pm
by walterheisenberg
This problem is still existant in v1.1

The CPU freq can't be changed with
machine.freq(80000000)
to 80MHz

Re: Changing the CPU frequency on ESP32

Posted: Sun Feb 03, 2019 5:08 am
by mattyt
Yes, the implementation of freq() is actually commented out in MicroPython.

Apparently it wasn't working in the ESP-IDF - but I've heard that recently it was resolved. Anyone know? Should be pretty easy to add if it's now working...