Sub-microsecond delay on Teensy 4

Status
Not open for further replies.

KingK

New member
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.
 
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
 
Is this going to be documented somewhere. If not it is likely to go unknown by anybody who have not seen this thread or maybe has forgotten about it.
 
I can add something tomorrow. Currently there is only information about the cycle counter and how to extend it to 64bit in it. https://github.com/TeensyUser/doc/wiki/Using-the-cycle-counter

Great - just wanted to make a note as it occurred before forgotten. Did a quick search and came up empty.

Not sure if 'Timing' in some form deserves its own section? Could expand to include all matters on doing things? {time controlled or background execution}:: Delay??, elapsed??, ??Timer??, _isr(), DMA, TeensyThreads, other?

BTW: on starting ARM_DWT_CYCCNT : rather than just starting it, not that it hurts? Found his to work >> if ( ARM_DWT_CYCCNT == ARM_DWT_CYCCNT ) { //start CYCCNT }
 
I already added a draft with notes about the content. If it gets big enough we might think of a own section indeed. https://github.com/TeensyUser/doc/wiki/Timers-and-delays

He he, very smart :) I'll add that.

Yes, you did add a timer/delay placeholder. Given how a whole page was filled with (the very nice) cycles64() - it seemed a page with examples could be made for those others as well - and having a 'main' Section would make it easier to find as it is a common question - or things folks SHOULD question - to do things better.

... smart ... :)
 
I added a top level section "Timing, delays and clocks" and filled in some information about delayXX, millis and the elapsedXX functions. It also contains links to a recent dive into the std::chrono clock system and a high resolution teensy clock implementation.
I'll fill in the timer sections later.

https://github.com/TeensyUser/doc/wiki

Let me know if you miss something.
 
Status
Not open for further replies.
Back
Top