From: "Alexei A. Frounze" Newsgroups: comp.os.msdos.djgpp Subject: Re: Any comments about using RDTSC to sync code ? Date: Sun, 1 Apr 2001 00:49:53 -0500 Organization: Global Crossing Telecommunications Lines: 30 Sender: UNKNOWN AT 209-130-218-209 DOT nas1 DOT roc DOT gblx DOT net Message-ID: <9a6ffj$s4s$1@node17.cwnet.frontiernet.net> References: <3ACABB23 AT MailAndNews DOT com> NNTP-Posting-Host: 209-130-218-209.nas1.roc.gblx.net X-Trace: node17.cwnet.frontiernet.net 986104115 28828 209.130.218.209 (1 Apr 2001 05:48:35 GMT) X-Complaints-To: abuse AT frontiernet DOT net NNTP-Posting-Date: 1 Apr 2001 05:48:35 GMT X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Eduardo TUDA Lorenzetti Pellini" wrote in message news:3ACABB23 AT MailAndNews DOT com... > Hi DJGPP friends, > > I'm doing a real time app using DJGPP that runs for almost 2 hours polling > and > reading some hardware ports in loops of 50 usec (*micro*seconds). > I'm using the Pentium TSC counter to sync the data acquision since the RTC > and > system timer don't have this desired resolution or have some undesired > granularity. > > The first problem i am living is to accurately calculate the CPU clock to > stablish the relationship between system clocks and real time. Just calculate average period of the clock by using RDTSC and the timer during 1 second (you may read time from RTC instead of BIOS tick counter or custom IRQ0 ISR). I don't know what kind of accuracy you need, but this will probably give you satisfactory level of accuracy... Good Luck -- Alexei A. Frounze alexfru [AT] chat [DOT] ru http://alexfru.chat.ru http://members.xoom.com/alexfru/ http://welcome.to/pmode/