On Thu, Mar 25, 2021 at 2:22 PM Grr <gebbe...@gmail.com> wrote: > > 1nsec means 1GHz, it is very hard to achieve the required accuracy even > > with the high end CPU. But since the standard defines nano_sleep, > up_ndelay > > looks not so unreasonable. > > > > I don't mean 1 ns > > I mean delays in the order of _dozens_ of ns > > 100 MHz (a very reasonable frequency nowadays) means 10 ns per cycle, so a > standard function that eases the task of delaying a few cycles for things > like hold times is a _very_ needed tool
What about the ASM function Fotis shared earlier in this thread? If you're not on an ARM CPU it would just need translation of the ASM instructions for that CPU. I recommend to make macros that given a delay time in ns will take into account the delay loop calibration Greg mentioned, and run the ASM delay loop. That way, there is only one calibration to make for ns, us, and ms. Cheers, Nathan