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

Thread: Teensy 4 measuring period between two interrupts, with nanosecond resolution

  1. #1

    Teensy 4 measuring period between two interrupts, with nanosecond resolution

    Hello...

    FIRST QUESTION:

    I need to measure the timing between a sync pulse and several other pulses, to a resolution of a couple of nanoseconds. In the ESP32 there is ESP.getCycleCount(), which gives the number of processor cycles that have elapsed since the processor turned on. With a 240MHz clock, the ESP32 returned a period with a 4.167ns resolution, give or take a few cycles for interrupt service, reading etc.

    Is there something similar in the Teensy 4.0 that can yield timing resolution to a couple of nanoseconds. Mine is a ToF application using radio pulses, something like a radar...

    SECOND QUESTION:

    Using the Teensyduino, is there a way to overclock the Teensy 4.0? If so, how and to what frequency can it be clocked safely at say, an ambient temperature of 25 deg Celsius?

    Thank you.

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    10,093
    Yes T_3.x and T4 have ARM_DWT_CYCCNT, see this post : pjrc.com/threads/58321-micros()-within-Interrupt-possible. Using that ARM_DWT_CYCCNT takes only about 3 cycles as it is a register read - not a function.

    As far as MCU Speed - with current IDE and TeensyDuino 1.48 installed the 'Tools / CPU Speed' menu item has options for setting CPU speed at compile time. It can also be adjusted at runtime with set_arm_clock().

    Selecting under 900 MHz can generally run without adding a fan or heatsink where ambient air and setup allows heat removal - the menu notes at speeds above that 'Cooling Required'.

    There is a tempmonGetTemp() call that can be made to get the internal measured CPU temp that will give some degree of feedback - but overclocking without enough cooling will hang/harm the processor at times before that number goes as high as it will function normally at lower speeds.

  3. #3
    Junior Member
    Join Date
    Nov 2019
    Location
    Nizhny Novgorod, Russia
    Posts
    14
    Teensy can measure time interval with timer resolution which equals to F_BUS. It's 150MHz on Teensy 4.0 with 600MHz clock, 200MHz when overclocked to 800MHz, 250MHz when overclocked to 1GHz (with good heatsink).
    There is a useful library, FrequencyMeasure (FrequencyMeasureMulti). I'm not sure if they already ported to Teensy 4.0 or not.

    But if using of external IC via SPI is acceptable, you can try specialized time-of-fly (time-to-digital) converter IC.
    E.g. TDC2700 has 55 picoseconds resolution or even better if averaging is used.

  4. #4
    Quote Originally Posted by defragster View Post
    Yes T_3.x and T4 have ARM_DWT_CYCCNT, see this post : pjrc.com/threads/58321-micros()-within-Interrupt-possible. Using that ARM_DWT_CYCCNT takes only about 3 cycles as it is a register read - not a function.

    As far as MCU Speed - with current IDE and TeensyDuino 1.48 installed the 'Tools / CPU Speed' menu item has options for setting CPU speed at compile time. It can also be adjusted at runtime with set_arm_clock().

    Selecting under 900 MHz can generally run without adding a fan or heatsink where ambient air and setup allows heat removal - the menu notes at speeds above that 'Cooling Required'.

    There is a tempmonGetTemp() call that can be made to get the internal measured CPU temp that will give some degree of feedback - but overclocking without enough cooling will hang/harm the processor at times before that number goes as high as it will function normally at lower speeds.
    Thank you, @defragster. very valuable info...

  5. #5
    Quote Originally Posted by Vadim Lopatin View Post
    Teensy can measure time interval with timer resolution which equals to F_BUS. It's 150MHz on Teensy 4.0 with 600MHz clock, 200MHz when overclocked to 800MHz, 250MHz when overclocked to 1GHz (with good heatsink).
    There is a useful library, FrequencyMeasure (FrequencyMeasureMulti). I'm not sure if they already ported to Teensy 4.0 or not.

    But if using of external IC via SPI is acceptable, you can try specialized time-of-fly (time-to-digital) converter IC.
    E.g. TDC2700 has 55 picoseconds resolution or even better if averaging is used.
    Thank you @Vadim, specially for the TDC2700!

Posting Permissions

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