Page 1 of 1
Delay
Posted: Tue Sep 16, 2003 11:00 pm
by Puh
How can i write a delay function?
RE:Delay
Posted: Tue Sep 16, 2003 11:00 pm
by carbonBased
I would say, probably the best way, would be to utilize the timer interrupt or rtc.
Increment a counter by 1 on each tick, in the interrupt. Your delay method can then grab the current value, and wait for a specific value knowing that, for example, this counter is going to increment 100 times in a second.
Cheers,
Jeff
RE:Delay
Posted: Tue Sep 16, 2003 11:00 pm
by knicos
You could also create a loop of nop instructions.
All you need to do is lookup how many clock cycles the instruction(s) take and then find out the clock frequency of the cpu. Then simply loop as long as needed. This makes smaller delays than the interrupt ( 100ns ).
RE:Delay
Posted: Mon Sep 29, 2003 11:00 pm
by Ramanan
Hi,
'in' or 'out' instruction cause one microsecond delay in any CPU (some where in the internet i red this). So use this in or out on a port 0x80 to delay. port 0x80 is safe and nothing will happen when u use these instructions on 2 it.
Do 1000 IN (or OUT, any one) to get the 1 millisecond delay. Do 1000000 IN to get the i second delay.
rgds,
YogaRamanan.T
RE:Delay
Posted: Tue Sep 30, 2003 11:00 pm
by Robert Lee
You could also wait for the vertical retrace for reasonably long delays (1/60th of a second or longer). The ports to do this are standard on VGA. Look it up.