Skip to content

Commit 80ea521

Browse files
authored
Add support for 160MHz rated CPUs (#3135)
Some ESP32 chips are rated only to 160MHz. This change adds support for them and does not allow frequency to be switched to 240MHz
1 parent 5c04de6 commit 80ea521

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cores/esp32/esp32-hal-cpu.c

+10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "soc/rtc_cntl_reg.h"
2424
#include "rom/rtc.h"
2525
#include "soc/apb_ctrl_reg.h"
26+
#include "soc/efuse_reg.h"
2627
#include "esp32-hal.h"
2728
#include "esp32-hal-cpu.h"
2829

@@ -150,6 +151,15 @@ bool setCpuFrequencyMhz(uint32_t cpu_freq_mhz){
150151
}
151152
return false;
152153
}
154+
//check if cpu supports the frequency
155+
if(cpu_freq_mhz == 240){
156+
//Check if ESP32 is rated for a CPU frequency of 160MHz only
157+
if (REG_GET_BIT(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_CPU_FREQ_RATED) &&
158+
REG_GET_BIT(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_CPU_FREQ_LOW)) {
159+
log_e("Can not switch to 240 MHz! Chip CPU frequency rated for 160MHz.");
160+
cpu_freq_mhz = 160;
161+
}
162+
}
153163
//Get current CPU clock configuration
154164
rtc_clk_cpu_freq_get_config(&cconf);
155165
//return if frequency has not changed

0 commit comments

Comments
 (0)