High precision event timer
- by rahul jv
#include "target.h"
#include "xcp.h"
#include "LocatedVars.h"
#include "osek.h"
/**
* This task is activated every 10ms.
*/
long OSTICKDURATION;
TASK( Task10ms )
{
void XCP_FN_TYPE Xcp_CmdProcessor( void );
uint32 startTime = GetQueryPerformanceCounter();
/* Trigger DAQ for the 10ms XCP raster. */
if( XCPEVENT_DAQ_OVERLOAD & Xcp_DoDaqForEvent_10msRstr() )
{
++numDaqOverload10ms;
}
/* Update those variables which are modified every 10ms. */
counter16 += slope16;
/* Trigger STIM for the 10ms XCP raster. */
if( enableBypass10ms )
{
if( XCPEVENT_MISSING_DTO & Xcp_DoStimForEvent_10msRstr() )
{
++numMissingDto10ms;
}
}
duration10ms = (uint32)( ( GetQueryPerformanceCounter() - startTime ) / STOPWATCH_TICKS_PER_US );
}
What would be the easiest (and/or best) way to synchronise to some accurate clock to call a function at a specific time interval, with little jitter during normal circumstances, from C++? I am working on WINDOWS operating system now.
The above code is for RTAS OSEK but I want to call a function at a specific time interval for windows operating system. Could anyone assist me in c++ language ??