Change clock speed on Teensy 3.5

jeff0778

Member
Hi,
I've searched around but can't seem to find the correct code to allow me to change the clock speed on the Teensy 3.5

I've tried the following, but this actually looks like its for an older board and the compiler complains about the CLKPR being undefined.

Would someone be able to confirm the correct method to change the clock including the options for overclocking.

#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
#define CPU_16MHz 0x00
#define CPU_8MHz 0x01
#define CPU_4MHz 0x02
#define CPU_2MHz 0x03
#define CPU_1MHz 0x04
#define CPU_500kHz 0x05
#define CPU_250kHz 0x06
#define CPU_125kHz 0x07
#define CPU_62kHz 0x08

then call up..
CPU_PRESCALE(CPU_16MHz);
 
looks like i may have found a way to do this in the platformio.ini

using
;board_build.f_cpu = 2000000
board_build.f_cpu = 4000000
;board_build.f_cpu = 8000000
;board_build.f_cpu = 16000000
;board_build.f_cpu = 24000000
;board_build.f_cpu = 48000000
;board_build.f_cpu = 72000000
;board_build.f_cpu = 96000000
;board_build.f_cpu = 120000000
;board_build.f_cpu = 144000000
;board_build.f_cpu = 168000000
 
Yes, Speed should be set at compile/build time. It is a complex interrelation of clocks and settings, changing at run time is non-trivial and has side effects as some device/elements have clock expectations set at compile time.

The Arduino IDE implements this in menu items - adjusting in PIO seems to have been found.
 
Back
Top