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

Thread: Teensy 4.0 Main Clock Speed...

  1. #1
    Junior Member
    Join Date
    May 2019

    Teensy 4.0 Main Clock Speed...

    Hello All,

    I am using a Teensy 4.0 and runing Teensy - Tutorial 1 - Blink code.

    How can I figure out what speed is my MCU running at?
    Is there an easy way?
    Can I change it (let's say 1MHz)?

    Thanks lot,

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    On Teensy 4 there is a dynamic run time variable :: F_CPU_ACTUAL

    That will return the current speed in Hz. There are various fixed times that can be selected in the IDE during the build. The Teensy will be at that speed on entry to setup().

    There is a way to alter the speed at runtime. If using USB Serial - it functions perhaps as low as 24 MHz. The CPU speed can be made lower.

    extern "C" uint32_t set_arm_clock(uint32_t frequency); // required prototype
    void setup() {
      while ( !Serial );
      Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);
      if ( F_CPU_ACTUAL >= 600'000'000 )
    // Fun note the 'apostrophe' as shown above is ignored by the compiler, but makes the string of zeros easier to parse.
    // When used singly like 60'000 however can mess with editor parsing where it tries to find the matching '

  3. #3
    Junior Member
    Join Date
    May 2019
    I got it.

Posting Permissions

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