Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Change clock speed on Teensy 3.5

  1. #1
    Junior Member
    Join Date
    Dec 2019
    Posts
    17

    Change clock speed on Teensy 3.5

    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);

  2. #2
    Junior Member
    Join Date
    Dec 2019
    Posts
    17
    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

  3. #3
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    16,360
    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.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,802
    In Arduino, click Tools > CPU Speed. Changes take effect next time you upload.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •