Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   timers in user_routines_fast (http://www.chiefdelphi.com/forums/showthread.php?t=44183)

stephenthe1 17-02-2006 11:50

timers in user_routines_fast
 
hi, I'm trying to create a generic timer in user_routines_fast. I don't need any exact amount of time to be calculated, just about 2/3 of a second. the code I'm using basically acts like this:

static int counter = 0;

if (counter >= 20)
{
//now I'm at where I want to get after 20 program loops
counter = 0;
}
else
{
counter++;
}



but I'm not having any luck in the fast file. what am I doing wrong? I have no problems in user_routines, but in fast everything doesn't work timer-wise. any ideas or help? thanks.
Stephen

Mike Betts 17-02-2006 12:02

Re: timers in user_routines_fast
 
Stephan,

In user routines, you are counting loops timed by the master uP communicating with the OI. Each loop takes about 26 milliseconds so your counter should take about a half second to "trip".

In user routines fast, there is no such delay and the loop is timing as fast as it can, With a 40 MHz clock (and ignoring other code which you may have in the fast loop) your timer will "trip" in about 1 microsecond (maybe less).

Regards,

Mike

steven114 17-02-2006 12:35

Re: timers in user_routines_fast
 
It's highly recommended to use one of the hardware timers instead of counting loops. There's been extensive discussion on these guys and they aren't very difficult to use - you'll love them! :)


All times are GMT -5. The time now is 01:35.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi