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

Thread: Sub-microsecond delay on Teensy 4

  1. #1
    Junior Member
    Join Date
    Jul 2020
    Posts
    2

    Sub-microsecond delay on Teensy 4

    I'm trying to implement a simple software SPI for the Teensy 4.0 and I am looking for a way to get a very short delay of at least 25ns but optimally less than 100ns with something similar to delayMicroseconds. Is this possible, or is there a better software SPI solution already available.
    I can't use the hardware SPI pins because of the way my project is already laid out.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,756
    delayNanoseconds(25);

  3. #3
    Junior Member
    Join Date
    Jul 2020
    Posts
    2
    D'oh! Should have looked around before I posted. That's exactly what I need.

    Thank you!

  4. #4
    Which library includes it?

  5. #5
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,406
    Teensy 4.x with the 1062 processor - installed with TeensyDuino.

  6. #6
    Is there a version of delayNanoseconds for Teensy 3.2?
    I thought maybe using a Pit?

  7. #7
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,406
    The same code for T_4.x would generally work on T_3.x's { with F_CPU_ACTUAL changed to F_CPU }. The CycleCounter may need to be started if not in use, it is started before setup on the T_4.x's. The results and resolution would be a bit less with the clock speed differential.

    see:: ...\hardware\teensy\avr\cores\teensy4\core_pins.h

  8. #8
    Senior Member
    Join Date
    May 2015
    Location
    USA
    Posts
    647

Posting Permissions

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