Is it possible to overclock Teensy 3.5 beyond 168 MHz?

albnys

Member
I want to overclock the Teensy 3.5 above 168MHz (if possible).
I've seen some threads that mention that it could be possible, but in the Arduino IDE I do not have the option to choose anything above 168 MHz.
Does anybody know how to do it, or if it's possible?
 
I don't know if it will work, but I do know how you would try.

Edit mk20dx128.c and look for this line:

Code:
    #if F_CPU == 168000000
        MCG_C6 = MCG_C6_PLLS | MCG_C6_VDIV0(18); // config PLL for 168 MHz output

Try increasing MCG_C6_VDIV0 to 19, 20, etc. Each step will make it run slightly faster.

The USB might not work, so create a program which you can use to confirm whether the chip is running properly and which gives you a way to measure the relative speed. Plan on needing to press the Program button after you've uploaded any program where USB doesn't communicate.

If you find a setting you like where USB doesn't work directly from the main clocks, you can use the code which configures USB from the internal IRC48M oscillator. You'll also want to change the defines for F_CPU and F_BUS so all the timing sensitive functions like millis() and serial baud rates recompile for whatever speed you manage to achieve. But that would come at the end, after you've found the raw hardware settings. The first step is to just experiment with how fast you can run, without USB, and with everything running faster while the code is still built with config for 168 MHz.

Also look for these lines:

Code:
#elif F_CPU == 168000000
        // config divisors: 168 MHz core, 56 MHz bus, 28 MHz flash, USB = 168 * 2 / 7
        SIM_CLKDIV1 = SIM_CLKDIV1_OUTDIV1(0) | SIM_CLKDIV1_OUTDIV2(2) | SIM_CLKDIV1_OUTDIV4(5);
        SIM_CLKDIV2 = SIM_CLKDIV2_USBDIV(6) | SIM_CLKDIV2_USBFRAC;

Flash memory is the portion of the chip least capable of overclocking. You can increase SIM_CLKDIV1_OUTDIV4 to 6 or even 7 to cause the flash memory to run slower, relative to the CPU which you're increasing. Slowing the flash will let you push the CPU faster. The flash will give more wait states to the CPU so you get diminishing returns for certain types of code, but you can always use FASTRUN on your timing sensitive code you need to run fastest, which causes it to be allocated in single-cycle RAM.

The other part of the chip we've seen have trouble with overclocking is the MCLK generator for I2S. If you're not using I2S digital audio, then not an issue. If you are, test it carefully as you push to higher speed. A wrong waveform on the MCLK output is a sure sign you're pushing the hardware faster than it can reliably run.

But if you really need more speed, perhaps switching to Teensy 4.1 would be best? It's 600 MHz and the M7 core is dual issue, so you sometimes get 2 instructions per clock. M7 also has large caches and branch prediction, so even without dual issue, it tends to run code much faster than M4 even when running at the same clock speed.
 
Last edited:
Back
Top