Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

simulating interrupts in Window FrreeRTOS port

Posted by mdubon on December 29, 2016

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


simulating interrupts in Window FrreeRTOS port

Posted by rtel on December 29, 2016

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.


simulating interrupts in Window FrreeRTOS port

Posted by mdubon on December 29, 2016

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?


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS