Hello to all,
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:
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.
You don’t show the code for creating the tasks, but from your description, it sounds like vDummyTask and vSporadicTask are assigned to the same priority level, thus when the semaphore is given, vSporadicTask will not interrupt vDummyTask, but only be scheduled ready and take its turn at the next tick.
I will say that I have a somewhat similar structure in one of my projects, with a task that is woken up via a semaphore connected to a higher speed interrupt than the tick interrupt. and it runs fine. I will admit I don’t have the equivalent of your dummy task that is just wasting time.
My only suggestion would be (if possible) to trace with a debugger through the give and switch to see why the task isn’t starting.
The only thing I see that looks unusual to me is that the line m_testbuffer = alt_timestamp(); seems to keep setting the same variable each time, I would expect it to be m_testbuffer_ = alt_timestamp(); or something like that._