msc
msc

Reputation: 34658

Need nanosecond delay in Jetson nano board

I am completely new to Jetson Nano board and I need to generate 20ns delay in Jetson Nano board. But I have no idea about it. So can any one help me, how can get 20ns delay in jetson nano board. Is there any code snippet available to achieve nanosecond delay? Thanks in advance.

Upvotes: 0

Views: 442

Answers (1)

unknownperson
unknownperson

Reputation: 589

If you are using C (on Linux/UNIX), there is a function called nanosleep that allows you to sleep some number of nanoseconds. However, Ubuntu is not a real-time operating system. This means other processes (parts of the OS, or anything else that is running at the same time) may interrupt the execution of your program for short periods of time. This means doing something timing-critical with short delays will not work. If you were to try to use nanosleep to delay for 20ns, your program would probably wait much longer than that. From the man page linked above:

nanosleep() suspends the execution of the calling thread until either at least the time specified in *req has elapsed, or the delivery of a signal that triggers the invocation of a handler in the calling thread or that terminates the process.

If you were planning on using the 20ns delay to generate some kind of output on I/O pins, you may be able to use the existing interfaces on the Jetson (like SPI) that are implemented in hardware and therefore have more consistent timing. Otherwise, consider using a different type of device to generate the signals (like a fast microcontroller or FPGA) and use I2C, SPI, or something else to communicate your intentions to it from the Jetson.

If you needed this for keeping track of some amount of time passed in your program, using the system time is a much better option, and there are lots of ways to get this (though it's likely it will increment more slowly than every 20ns).

Upvotes: 1

Related Questions