We have GPIO interrupt that occur every 31.25 uSec.
I timestamp the TSCL, and check that time between each interrupt falls below 35 uSec. Allowing jitter of 3.75 uSec.
I also toggle LED on board when more than 100 measurements is not matching this condition.
Here is the code:
static const uint32_t CPU_FREQ_IN_MHZ = 750;
static const uint32_t MICROS_IN_ONE_MTS_UP_LIMIT = 35;
void mtsFPGAIsr() { cpu_timestamp = TSCL; if(once) { cpu_timestamp_prev = cpu_timestamp; once = 0; } delta_cpu_timestamp = cpu_timestamp - cpu_timestamp_prev; if(delta_cpu_timestamp > CPU_FREQ_IN_MHZ * MICROS_IN_ONE_MTS_UP_LIMIT) { if(delta_cpu_timestamp > delta_cpu_timestamp_max) delta_cpu_timestamp_max = delta_cpu_timestamp; delta_cpu_timestamp_more_than_mts_triggered_cntr++; delta_cpu_timestamp_more_than_mts_triggered_total++; if(delta_cpu_timestamp_more_than_mts_triggered_cntr > 100) { GPIO_toggle(BOARD_GPIO_LED_RED_AX1_DSP); delta_cpu_timestamp_more_than_mts_triggered_cntr = 0; } } cpu_timestamp_prev = cpu_timestamp; // aging }
When no tasks running, there is no jitter, and all good,
delta_cpu_timestamp_more_than_mts_triggered_total = 0
But when i create these test tasks, i start to have problems and
delta_cpu_timestamp_more_than_mts_triggered_total > 0,
Here are the tasks,
Void test_task_a(UArg arg0, UArg arg1) { while(true) { Task_sleep(1000); } } Void test_task_b(UArg arg0, UArg arg1) { OSAL_SemaphorePend(test_task_b_sem, OSAL_MAX_DELAY); } Void test_task_c(UArg arg0, UArg arg1) { OSAL_SemaphorePend(test_task_c_sem, OSAL_MAX_DELAY); }
- When in test_task_a i change the loop with sleep to blocking at semaphore, the number of time that latency occures is low and occurs rarely, but still occurs.
- When there is only 1 task with loop there is no latency in interrupt. or maybe does occur but very very rarely.
- Maximum latency is always 2 * 31.25, 3 * 31.25, which looks like skipping, maybe something that coming from hwi_disable() in Task_sleep(1000) or Sem_pen().
Note: There is no other tasks running except of TI-RTOS Idle task.
Please advise,
With best regard Vadim.