I’m working on measurements over FreeRTOS for a thesis in Computer Engineering. I’m using FreeRTOS over NIOS II processor in an Altera FPGA and a custom made board.
Here is what i’m trying to verify:
A task is blocked on a semaphore, released by an hardware interrupt that fires once every 650us. I want to see if the task keep the same period of the interrupt and what is the latency of using this method (a task waiting for a semaphore) for interrupt management.
When the Interrupt management task is executed alone everything is fine: i can see it starting once every 650 us. If I try it with other lower priority tasks I found that the task is launched once every 2ms, that is the RTOS tick period.
It seems to me that the context switch that should wake the interrupt management task doesn’t occur until the intervention of FreeRTOS kernel, instead of being forced by the semaphore release function and the macro portEND_SWITCHING_ISR.
Am I doing something wrong?
Thanks for your help.
Here’s my source code:
static void test_irq(void* context){
portBASE_TYPE highPrioWoken = pdFALSE;
IOWR(CONTATORE_AVALON_0_BASE, 6, 0);
xSemaphoreGiveFromISR(semaphore, &highPrioWoken);
portEND_SWITCHING_ISR(highPrioWoken);
}
static portTASK_FUNCTION( vSporadicTask, pvParameters ){
int i;
for(i = 0; i<NUMTEST; i++){
xSemaphoreTake(semaphore, portMAX_DELAY);
m_testBuffer[i] = alt_timestamp();
}
tst_put_open();
tst_put_string("name", "SporadicTest");
tst_put_int("numtest", NUMTEST);
tst_put_int("numtask", NUMTASK);
tst_put_ulong("TickFreq", alt_timestamp_freq());
tst_put_ulongbuffer("data", m_testBuffer, NUMTEST);
tst_put_close();
vTaskSuspend(NULL);
}
static portTASK_FUNCTION( vDummyTask, pvParameters ){
int m_dummyVar = 0;
for(;;){
m_dummyVar++;
}
}
Functions starting with tst_put_ are custom functions used to put the array containing the timestamps on standard output so that i can retrieve and analyse it. However they are called after the test is completed so they should not affect the correct behaviour of the task.