Re: Timer with Micro seconds



I can't see anything glaringly wrong with your code. Have you checked
the implementation of the performance counter? Why not try a simple
loop to see that it's running properly and generating sensible
values....

for( int i=0; i<10; i++ )
{
LARGE_INTEGER perfCntVal;
QueryPerformanceCounter( &perfCntVal );
printf("perfCntVal = 0x%08X%08X\n", perfCntVal.HighPart,
perfCntVal.LowPart);
Sleep(100);
}

Andrew.

On Nov 20, 10:25 am, Chandra <forquer...@xxxxxxxxx> wrote:
On Nov 20, 2:26 pm, "Andrew at Plextek (www.plextek.co.uk)"

<a...@xxxxxxxxxxx> wrote:
I've successfully used the performance counter at application level.
Andrew.

Hi Andrew,

Thanks for quick reply. I am able to configure the Performance
Counter, but my application is hanging when i try to use it. The code
which i am using is as below.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

LARGE_INTEGER liDelay;
// Query number of ticks per second
if (QueryPerformanceFrequency(&liDelay))
{
// 1ms delay
liDelay.QuadPart /= 1000;

LARGE_INTEGER liTimeOut;
// Get current ticks
if (QueryPerformanceCounter(&liTimeOut))
{
// Create timeout value
liTimeOut.QuadPart += liDelay.QuadPart;
LARGE_INTEGER liCurrent;
do
{
// Get current ticks
QueryPerformanceCounter(&liCurrent);
// Delay until timeout
} while (liCurrent.QuadPart<liTimeOut.QuadPart);
}
}

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

liDelay.QuadPart /= 1000; // for milli seconds divide by 1000
liDelay.QuadPart /= 1000; // for second divide by 1

The statement i am varying according to my requirement. But only thig
is when i am trying to get microseconds delay with this code, my
application is getting hanged and it is terminating itself. Any
suggestion from you will be a great help to me. Hope you understand my
problem.

With warm regards,

Chandra.

.



Relevant Pages

  • Re: Timer with Micro seconds
    ... but my application is hanging when i try to use it. ... // Query number of ticks per second ... // Create timeout value ... // Delay until timeout ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Why there is so big difference between "uCOSII" and "Plain ARM"
    ... sysDelayNS(600) will delay about 2 second. ... It is probably because uCOS is an RTOS and has a built in system timer ... It is normally set to between 50 and 200 ticks per second. ... your loop, unless your loop is in the highest priority ready task. ...
    (comp.sys.arm)

Loading