Using:
- Stm32F10x, F2xx, F4xx
- FreeRtos 8.1.1
- gcc-arm-none-eabi-4_8-2014q2
I have an ISR which must run with high interrupt priority, so that's forbidden to call FreeRtos Api from within this ISR (see here and here).
In some cases these ISR detects conditions, for which a sleeping FreeRtos task should be waked up with at least possible latency.
Normally (if the ISR was allowed to call FreeRtos Api because of enough low priority) I would use a queue or semaphore to solve this.
But how to realize that with a high priority ISR?
My current interims approach is like this (briefly outlined):
volatile int flag = 0;
void XYZ_IRQHandler() {
if (someCondition)
flag = 1
}
void FreeRtosTaskFunction(void* parameters) {
for (;;) {
if (flag == 1)
doSomething();
vTaskDelay(1); // sleep 10ms (tick frequency is 100Hz)
}
}
But this approach has the disadvantages:
- Latency (from setting the flag in ISR until task wakeup) to is up to 1 FreeRtos tick.
- Need to poll the flag (waste of cpu cycles).
Any suggestions to solve this in a better way, especially with less latency?