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?
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.