At 05:13 PM 10/1/2002 +0200, Daniel Morais wrote:
>Le mardi, 1 oct 2002, � 16:24 Europe/Paris, Dan a �crit :
>
>>I'm trying to implement a delay of 0.5 milliseconds in my code, 
>>however the
>>Palm OS System tick functions can only gives me a resolution of 
>>0.01 second
>>for each tick. Is there any other way that I can achieve that? 
>>such as
>>inserting NOP in assembly code??
>
>
>In fact, you should not rely on ticks been updated every 1/100 
>or 1/60 ( I think POSE use the later ), but use 
>SysTicksPerSecond() to get the exact value used on the device 
>your code is running.
>
>As dave mentionned it, I remember someone posted an interresting 
>exemple of a millisecond timer.
>If you don't find it, you can use the ( simple ) following 
>principle :
>
>- do a loop doing some stuff that last exactly 1 second.
>- divide the number of time your loop was running by 200 to get 
>a 5 ms delay
>
>Of course, this need some tuning to work correctly, but the 
>principle should work.

Yes, the code needs to be self-tuning: upon launch of your 
application, call a timer-tuning routine that calls *exactly the 
same code that you will subsequently be using to execute delays*, 
and see how much time the loop takes according to the real-time 
clock.  AutoCAD on MS-DOS successfully used this approach to 
provide pretty accurate programmable delays.


--
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to