Other Parts Discussed in Thread: CC3200
edit 2015-12-01: it seems not an issue with the timers, but GPIO interupt triggering on the wrong edge, please follow this thread to the end.
I was wondering what accuracy I can reach with the internal timer functions?
I have a pretty straight forwarded application that starts a timer on a gpio interupt input. The timer controls an other gpio pin. When I run this with a function generator on the input and put both signals on a scope, then I should see a constant distance between the 2 signals (if the timer is reliable).
At run this setup at 50Hz (10ms per puls on input). The timer is delaying 0-9ms fixed value. But my ouput pin (controlled from timer interup) is sometimes 1-2ms too late...
Some code:
on init:
//Initialize Push Botton Switch
Button_IF_Init(SW2InterruptHandler,SW3InterruptHandler);
//Enable GPIO Interrupt
Button_IF_EnableInterrupt(SW2); // not used yet
Button_IF_EnableInterrupt(SW3);
//Setup timer A0
UART_PRINT("Setup timer \n\r");
Timer_IF_Init(PRCM_TIMERA0, TIMERA0_BASE, TIMER_CFG_ONE_SHOT, TIMER_A, 0); // Configuring the timers
Timer_IF_IntSetup(TIMERA0_BASE, TIMER_A, TimerA0IntHandler); // Setup the interrupts for the timer timeouts.
void SW3InterruptHandler(void)
{
unsigned long ulDelay; // unit is 0.1ms
ulDelay = 50; // 5ms
//start timer
Timer_IF_Start(TIMERA0_BASE, TIMER_A, (PERIODIC_TEST_CYCLES / 10000) * ulDelay); // Turn on the timers
Button_IF_EnableInterrupt(SW3);
}
static void
TimerA0IntHandler(void)
{
static unsigned char ucState=0;
// Clear the timer interrupt.
Timer_IF_InterruptClear(TIMERA0_BASE);
if (ucState == 0)
{
GPIO_IF_LedOn(MCU_GREEN_LED_GPIO);
Timer_IF_Start(TIMERA0_BASE, TIMER_A, (PERIODIC_TEST_CYCLES / 1000) ); // Turn on 1ms timer to turn of output after 1 ms (ucState=1)
ucState=1;
}
else
{
GPIO_IF_LedOff(MCU_GREEN_LED_GPIO);
ucState=0;
}
}
Most code copied from examples. I havenot played around with interupt priorities. In timer_if.c I left this at INT_PRIORITY_LVL_1.
Any ideas? Am I asking to much resolution from this system?

