FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [December 2016 Threads]
Hello everyone,
I am a newbie to FreeRtos and currently working on the windows port. The provided example is working fine and I also could use the interface to generate interrupts. But I do have a conceptional question about all that.
I created a simple demo code
~~~
include
include
/* Kernel includes. */
include "FreeRTOS.h"
include "task.h"
static HANDLE gThread;
define INTERRUPT_ID 0x11
TaskHandle_t gFreeRtosTaksHandler;
uint32_t myISR(void) {
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
/* Unblock the handling task so the task can perform any processing
necessitated by the interrupt. xHandlingTask is the task's handle, which was
obtained when the task was created. vTaskNotifyGiveFromISR() also increments
the receiving task's notification value. */
vTaskNotifyGiveFromISR(gFreeRtosTaksHandler, &xHigherPriorityTaskWoken);
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
DWORD WINAPI someThread(void* data) {
DWORD dwError;
if (!SetThreadPriority(GetCurrentThread(), THREADPRIORITYTIMECRITICAL))
{
dwError = GetLastError();
printf("error (%d)n", dwError);
return -1;
}
Sleep(1000);
while (1) {
myISR(); // a direct call of the myISR does not lead to an task notification
//vPortGenerateSimulatedInterrupt(INTERRUPTID); // this is working
Sleep(1000);
}
return 0;
}
void freeRtosTask(void *pvParameters)
{
const TickTypet xBlockTime = 5000000;
uint32t ulNotifiedValue;
for (;; )
{
ulNotifiedValue = ulTaskNotifyTake(pdTRUE,
xBlockTime);
// HERE's the problem: I am NOT receiving any notification when myISR is directly called
printf("Hallo\n");
}
}
int main(void)
{
gThread = CreateThread(NULL, 0, someThread, NULL, 0, NULL);
xTaskCreate(freeRtosTask, /* The function that implements the task. /
"foo", / The text name assigned to the task - for debug only as it is not used by the kernel. /
configMINIMALSTACKSIZE, / The size of the stack to allocate to the task. /
NULL, / The parameter passed to the task - not used in this simple case. /
tskIDLE_PRIORITY + 5,/ The priority assigned to the task. /
&gFreeRtosTaksHandler); / The task handle is not required, so NULL is passed. */
vPortSetInterruptHandler(INTERRUPT_ID, myISR);
vTaskStartScheduler();
for (;; );
}
~~~
When I am using in the "someThread" function the vPortGenerateSimulatedInterrupt call, the notification is received. But when I do a direct call of my ISR in the "someThread" function the notification is not received.
I did not yet dive in the debugging but I'd like to have some feedback about this concept from the community. IMHO the direct call is closer to the real use case when working on an microcontroller but I am not sure about that nor do I know if my code can work.
Any hints and comments are very appreciated.
Thanks
Matthias
Please use the port in the way it is intended, which is the way the example code uses it. You should not be creating Windows threads directly. Only threads created using the FreeRTOS API will be part of the FreeRTOS application, and threads that are not part of the FreeRTOS application (any other Windows thread) cannot communicate with threads that are.
Ok I understand that. But what about ISR, an ISR is not a FreeRTOS thread and on a uC target platform an ISR can notify a FreeRtos thread. In my oppinion that should also be working on windows: the (high priortity) Window thread is the equivalent of an uC ISR. Can you help me understand if (resp. why) this analogy is not true?
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.