I have a Fez Panda II with DIO34 connected to the pulse-per-second (PPS) signal on a GPS module. I am trying to precisely measure the processor’s time when PPS is asserted, in order to measure the error of the processor’s clock.
What I’m doing seems to work fine when the Fez is otherwise idle, but when I start introducing a lot of UART traffic, I start to see much more imprecision in my measurements.
This is the RLP code I am using:
void PPS_Interrupt ( unsigned int Pin, unsigned int PinState, void* Param )
{
RLPext->PostManagedEvent(0);
}
int InitPPS(unsigned int *generalArray, void **args, unsigned int argsCount, unsigned int *argData)
{
RLP_InterruptInputPinArgs Args;
Args.GlitchFilterEnable = RLP_TRUE; // Enable Glitch Filter
Args.IntEdge = RLP_GPIO_INT_EDGE_HIGH; // Interrupt on Rising Edge
Args.ResistorState = RLP_GPIO_RESISTOR_PULLUP; // Enable internal pull-up resistor
RLPext->GPIO.EnableInterruptInputMode(
12, // unsigned int Pin,
&Args, // RLP_InterruptInputPinArgs *args,
PPS_Interrupt, // RLP_GPIO_INTERRUPT_SERVICE_ROUTINE ISR,
(void*)0 // void* ISR_Param
);
return 0;
}
and this is the prototype of the RLP Event handler:
static void RLP_RLPEvent(uint data, DateTime TimeStamp)
The TimeStamp value has a precision of 0.1 microseconds, which is great, and I have been able to use this to measure the Fez clock’s error as about 26 microseconds fast; here is what a sequence of my measurements look like:
-26.3
-26.4
-26.4
-26.4
-26.4
-26.4
-26.3
-26.4
-26.4
-26.4
-26.3
-26.4
-26.3
-26.4
-26.4
-26.4
-26.3
-26.3
-26.4
-26.3
-26.4
-26.3
-26.3
-26.4
-26.4
-26.3
-26.3
-26.3
-26.4
-26.3
The problem I’m having is when I start to introduce a lot of UART traffic, my measurements start to look a lot more imprecise, for example:
-26.2
-26.3
-26.2
-26.3
-26.3
-19.7
-32.8
-26.3
-17.5
-35.1
-18.4
-34.1
-17.6
-35.1
-26.3
-26.3
-17.5
19.7
-72.3
-35.2
-26.3
-26.4
-26.3
-17.5
-26.4
-35.1
-26.3
-26.4
-17.5
-26.3
-35.2
I’m guessing that the UART interrupt handler is preventing my GPIO handler from running immediately, causing software latency in the TimeStamp measurement. Does this sound reasonable, and if so, is there a way around this problem?
Thanks,
-Frank