R
Rafal M
Hi,
Is it possible to create timer 9600/s in C?
Regards,
Rafal
Is it possible to create timer 9600/s in C?
Regards,
Rafal
Rafal said:Hi,
Is it possible to create timer 9600/s in C?
Is it possible to create timer 9600/s in C?
Is it possible to create timer 9600/s in C?
Walter said:[...]
Portable C does not offer any facilities for triggering actions
after particular lengths of time (at any precision), and the
highest resolution time-of-day counter it has is clock()
which increments CLOCKS_PER_SEC times a second. [...]
Rafal said:Hi,
Is it possible to create timer 9600/s in C?
Regards,
Rafal
Walter said:Portable C does not offer any facilities for triggering actions
after particular lengths of time (at any precision), and the
highest resolution time-of-day counter it has is clock()
which increments CLOCKS_PER_SEC times a second. [...]
First, clock() measures CPU time, not time of day.
For the latter, you need time().
Second, the clock() value does not necessarily increment
CLOCKS_PER_SEC times per second, nor even per CPU second.
The value is *stated* in units of 1/CLOCKS_PER_SEC seconds,
but that doesn't imply that it's *measured* in those units.
Rafal M said:Why 100us not work (is slow)?
HANDLE hTimer = NULL;
LARGE_INTEGER liDueTime;
liDueTime.QuadPart=-1000 // 100ns*1000 =100us
// Create a waitable timer.
hTimer = CreateWaitableTimer(NULL, TRUE, "WaitableTimer");
while (true)
{
SetWaitableTimer(hTimer, &liDueTime, 0, NULL, NULL, 0);
if (WaitForSingleObject(hTimer, INFINITE) != WAIT_OBJECT_0)
{
printf("failed");
}
else
{
printf("T");
}
}
That code fragment is extremely system-specific, and therefore
off-topic in this newsgroup. I don't even know what system it applies
to.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.