Hello,
I am working on a project that requires a very accurate timer/clock. I need a periodic interrupt every 100ms to read counter to calculate incoming frequency.
The code i am using today shifts with about 2ms when i measured with a oscilloscope. Does anyone know how to get a more accurate interrupt?
As you can see from the code below, I made sure the external crystal is used.
void *main_control_task(void *arg0, void *arg1)
{
UNUSED(arg0);
UNUSED(arg1);
main_control_initialise_event();
(void)rtc_init(0);
OSCHF_TurnOnXosc();
while(!OSCHF_AttemptToSwitchToXosc())
{
}
while(1)
{
// .......
// customer code
// ......
}
static void measurement_clock_init(void)
{
uint32_t period = 100 * (1000 / ClockP_getSystemTickPeriod()) + 2;
/* Construct BIOS Objects */
Clock_Params clkParams;
Clock_Params_init(&clkParams);
clkParams.period = period;
clkParams.startFlag = TRUE;
/* Construct a periodic Clock Instance */
Clock_construct(&clk0Struct, (Clock_FuncPtr)measurement_cb,
period *10U, &clkParams);
}
Any response is appreciated.
Thx,
Ole

This is how the crystal is mounted on our custom board.