├── ESP32_OVERCLOCK_EXP └── ESP32_OVERCLOCK_EXP.ino └── README.md /ESP32_OVERCLOCK_EXP/ESP32_OVERCLOCK_EXP.ino: -------------------------------------------------------------------------------- 1 | //******************************************************************************** 2 | //* * 3 | //* SIMPLE ESP32 OVERCLOCK EXPERIMENT * 4 | //* * 5 | //******************************************************************************** 6 | //* * 7 | //* Do everything at your own risk!!! * 8 | //* * 9 | //* TESTED on WROVER B with 40MHz crystal oscillator * 10 | //* * 11 | //* increasing speed of ESP32 cause timing changes of all system... * 12 | //* * 13 | //******************************************************************************** 14 | 15 | //******************************************************************************** 16 | // >>>> HERE: 17 | 18 | uint8_t OVERCLOCK=1; 19 | 20 | //0 = 1.000x of speed = no overclock 21 | //1 = 1.290x of speed 22 | //2 = 1.414x of speed 23 | //3 = 1.540x of speed 24 | //4 = 1.666x of speed 25 | 26 | //******************************************************************************** 27 | 28 | #include "soc/rtc_wdt.h" 29 | #include "esp_int_wdt.h" 30 | #include "esp_task_wdt.h" 31 | #include "soc/soc.h" 32 | #include "soc/rtc.h" 33 | #include "soc/dport_reg.h" 34 | #include "rom/ets_sys.h" 35 | #include "soc/rtc.h" 36 | #include "soc/rtc_periph.h" 37 | #include "soc/apb_ctrl_reg.h" 38 | #include "sdkconfig.h" 39 | 40 | 41 | extern "C" { 42 | // ROM functions which read/write internal control bus 43 | uint8_t rom_i2c_readReg(uint8_t block, uint8_t host_id, uint8_t reg_add); 44 | uint8_t rom_i2c_readReg_Mask(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t msb, uint8_t lsb); 45 | void rom_i2c_writeReg(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t data); 46 | void rom_i2c_writeReg_Mask(uint8_t block, uint8_t host_id, uint8_t reg_add, uint8_t msb, uint8_t lsb, uint8_t data); 47 | } 48 | 49 | //******************************************************************************** 50 | 51 | #define I2C_BBPLL 0x66 52 | #define I2C_BBPLL_ENDIV5 11 53 | #define I2C_BBPLL_BBADC_DSMP 9 54 | #define I2C_BBPLL_HOSTID 4 55 | #define I2C_BBPLL_OC_LREF 2 56 | #define I2C_BBPLL_OC_DIV_7_0 3 57 | #define I2C_BBPLL_OC_DCUR 5 58 | 59 | #define BBPLL_ENDIV5_VAL_320M 0x43 60 | #define BBPLL_BBADC_DSMP_VAL_320M 0x84 61 | #define BBPLL_ENDIV5_VAL_480M 0xc3 62 | #define BBPLL_BBADC_DSMP_VAL_480M 0x74 63 | 64 | 65 | #define I2C_WRITEREG_MASK_RTC(block, reg_add, indata) \ 66 | rom_i2c_writeReg_Mask(block, block##_HOSTID, reg_add, reg_add##_MSB, reg_add##_LSB, indata) 67 | 68 | #define I2C_READREG_MASK_RTC(block, reg_add) \ 69 | rom_i2c_readReg_Mask(block, block##_HOSTID, reg_add, reg_add##_MSB, reg_add##_LSB) 70 | 71 | #define I2C_WRITEREG_RTC(block, reg_add, indata) \ 72 | rom_i2c_writeReg(block, block##_HOSTID, reg_add, indata) 73 | 74 | #define I2C_READREG_RTC(block, reg_add) \ 75 | rom_i2c_readReg(block, block##_HOSTID, reg_add) 76 | 77 | 78 | 79 | 80 | //******************************************************************************** 81 | 82 | void OVERCLOCK_ME(uint8_t OC_LEVEL) { 83 | I2C_WRITEREG_RTC(I2C_BBPLL, I2C_BBPLL_ENDIV5, BBPLL_ENDIV5_VAL_480M); 84 | I2C_WRITEREG_RTC(I2C_BBPLL, I2C_BBPLL_BBADC_DSMP, BBPLL_BBADC_DSMP_VAL_480M); 85 | 86 | uint8_t div_ref; 87 | uint8_t div7_0; 88 | uint8_t div10_8; 89 | uint8_t lref; 90 | uint8_t dcur; 91 | uint8_t bw; 92 | 93 | div_ref = 0; 94 | 95 | if (OC_LEVEL==1) { 96 | div7_0 = 40; // ~SQRT(5/3)x speed (~310MHz?) 97 | } else if (OC_LEVEL==2) { 98 | div7_0 = 48; // ~1.41421356x speed (~340MHz?) 99 | } else if (OC_LEVEL==3) { 100 | div7_0 = 56; // ~1.54044011x speed (~370MHz?) 101 | } else if (OC_LEVEL==4) { 102 | div7_0 = 64; // ~1.66666667x speed (~400MHz?) 103 | } else { 104 | div7_0 = 32; // 1x speed (240MHz) 105 | } 106 | div10_8 = 0; 107 | lref = 0; 108 | dcur = 6; 109 | bw = 3; 110 | 111 | uint8_t i2c_bbpll_lref = (lref << 7) | (div10_8 << 4) | (div_ref); 112 | uint8_t i2c_bbpll_div_7_0 = div7_0; 113 | uint8_t i2c_bbpll_dcur = (bw << 6) | dcur; 114 | I2C_WRITEREG_RTC(I2C_BBPLL, I2C_BBPLL_OC_LREF, i2c_bbpll_lref); 115 | I2C_WRITEREG_RTC(I2C_BBPLL, I2C_BBPLL_OC_DIV_7_0, i2c_bbpll_div_7_0); 116 | I2C_WRITEREG_RTC(I2C_BBPLL, I2C_BBPLL_OC_DCUR, i2c_bbpll_dcur); 117 | } 118 | //******************************************************************************** 119 | 120 | float TIMING; 121 | 122 | void setup() { 123 | 124 | if (OVERCLOCK==1) TIMING=1.290; //=SQRT(5/3) 125 | else if (OVERCLOCK==2) TIMING=1.41421356; //=SQRT(2); 126 | else if (OVERCLOCK==3) TIMING=1.54044011; //=? 127 | else if (OVERCLOCK==4) TIMING=1.66666667; //=5/3 128 | else TIMING=1; 129 | 130 | Serial.begin(115200 / TIMING); 131 | 132 | printf("NOT OVERCLOCKED = SERIAL BAD TIMING \n"); 133 | 134 | delay(1000); 135 | 136 | OVERCLOCK_ME(OVERCLOCK); 137 | 138 | delay(1000); 139 | 140 | printf("OVERCLOCK = SERIAL CORRECTED TIMING \n"); 141 | } 142 | 143 | 144 | void loop() { 145 | 146 | } 147 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SIMPLE-ESP32-OVERCLOCK-EXPERIMENT 2 | SIMPLE ESP32 SOFTWARE OVERCLOCK EXPERIMENT 3 | 4 | 5 | * Do everything at your own risk!!! 6 | * TESTED on WROVER B with 40MHz crystal oscillator 7 | * increasing speed of ESP32 cause timing changes of all system... 8 | 9 | --------------------------------------------------------------------------------