Changing the CPU frequency on ESP32

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
ZKDMun
Posts: 42
Joined: Thu Nov 24, 2016 2:34 pm
Location: Hamburg

Changing the CPU frequency on ESP32

Post by ZKDMun » Mon May 07, 2018 10:46 am

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.

OutoftheBOTS_
Posts: 556
Joined: Mon Nov 20, 2017 10:18 am

Re: Changing the CPU frequency on ESP32

Post by OutoftheBOTS_ » Mon May 07, 2018 10:52 am

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

ZKDMun
Posts: 42
Joined: Thu Nov 24, 2016 2:34 pm
Location: Hamburg

Re: Changing the CPU frequency on ESP32

Post by ZKDMun » Mon May 07, 2018 11:03 am

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)

walterheisenberg
Posts: 6
Joined: Sun Jan 27, 2019 11:50 am

Re: Changing the CPU frequency on ESP32

Post by walterheisenberg » Sat Feb 02, 2019 6:11 pm

This problem is still existant in v1.1

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

User avatar
mattyt
Posts: 215
Joined: Mon Jan 23, 2017 6:39 am

Re: Changing the CPU frequency on ESP32

Post by mattyt » Sun Feb 03, 2019 5:08 am

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...

Post Reply