I am trying to generate delay in CPU. For instance after writing a register, I want to read it again after 1000ns. What should be the C code or the assembly code for the same?
What's the processor and how precise does the timing need to be?
The processor is A72. I need to generate delay of around 1000ns and 20000ns.
Martin Weidmann said:how precise does the timing need to be?
MNB said:around 1000ns and 20000ns
That doesn't really answer the question!
BTW: It gets as bit hard to count all those zeros - "1us" and "20us" would be clearer.
And quicker for you to type!
What exactly do you mean by precision? Does it mean precision in percentage or if I am trying to have a delay of 1us and delay generated is 1us±precision? If not, it would be very helpful if you can explain with some example. I am new to the industry. So please bare with me :)
Do you need delays in us granularity or 100ns, 10ns or even 1ns.
Anyway Cortex-A system have a system timer. And SoCs have also timers.
So I suggest to pick one that runs fast enough for the precision you need, set it up for free running. The rest is common program techniques.
Granularity of 10ns would be fine. I will explore the timer thing you are telling.
The blank line illustrates that the function printed to my standard output, and I had to hit Enter to ensure I was on a prompt.
The upside of this method is that while the Timer thread was waiting, I was able to do other things, in this case, hitting Enter one time - before the function executed (see the first empty prompt).
There isn't a respective object in the multiprocessing library. You can create one, but it probably doesn't exist for a reason. A sub-thread makes a lot more sense for a simple timer than a whole new subprocess.
View all questions in Classic processors forum