Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delay routine

Status
Not open for further replies.

jscorpion

Programmer
Nov 17, 2000
40
US
I am pretty new to c++ programming. I am looking over some older source code that uses a counter routine to delay the process while it reads from a serial port. The problem is that this was written when 133mhz was fast but now it is to fast and reaches the max time before it is able to receive information back from the module we are scanning. I have documentation stating the time needed to receive a reading back using different baud rates. I could up the time to a long value, but the same problem would pop up again in another year. So my question is how can I do a time delay of 30ms. I would like it to scan the serial port in a while loop, if it gets the reading in it would change a value to one and kick out of the loop after it sees a 0x0d. I would also like the && to show a time delay of 30ms, if it reaches this time and has not scanned anything in then kick out of the loop. I would deeply appreciate any help I could get on this matter. I feel a time delay would be much more beneficial than a counter even though I have it set in an ini form for change.

Thank you!

jscorpion
 
I have no source here, but if you have a windows application you can use a standard timer of the Borland system.

hnd
hasso55@yahoo.com

 
You might find this code snippet useful. Enter argument in milliseconds...and wait. Use in Windows programming for GetTickCount function.

/********************************************************
* DELAYMS: millisecond delay *
********************************************************/
void delayMS(DWORD ms)
{
DWORD start=GetTickCount();
do{;} while((GetTickCount()-start)<ms);
}
/********************************************************/
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top