cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 H7755ZI- FREE RTOS- Task notification from ISR

STork.1
Associate III

Hello

I created a task that is needed to be executed from ISR. previously I did for ESP32 but using the same manner, I could not do it.

Based on my search, I found 2 ways which I tried but could not have my task run.

first manner:

Inside the ISR:

BaseType_t checkIfYeildRequired;
 
checkIfYeildRequired=xTaskResumeFromISR(ADXL_HandlerHandle);
 
portYIELD_FROM_ISR(checkIfYeildRequired);

Then first line of my task in for loop:

 vTaskSuspend(NULL);

Second Manner:

BaseType_t pxHigherPriorityTaskWoken = pdFALSE;
 
vTaskNotifyGiveFromISR(ADXL_HandlerHandle , &pxHigherPriorityTaskWoken);
 
if ( pxHigherPriorityTaskWoken == pdTRUE) {
 
portYIELD_FROM_ISR(pxHigherPriorityTaskWoken);

Then first line of my task in for loop:

ulTaskNotifyTake(pdTRUE, portMAX_DELAY);

How I created the task outside of the main function as a global variable:

/

* Definitions for ADXL_Handler */
 
osThreadId_t ADXL_HandlerHandle;
 
const osThreadAttr_t ADXL_Handler_attributes = {
 
 .name = "ADXL_Handler",
 
 .priority = (osPriority_t) osPriorityNormal,
 
 .stack_size = 1024 * 4
 
};
 
/* Definitions for Clock_Task */
 
osThreadId_t Clock_TaskHandle;
 
const osThreadAttr_t Clock_Task_attributes = {
 
 .name = "Clock_Task",
 
 .priority = (osPriority_t) osPriorityNormal,
 
 .stack_size = 256 * 4
 
};
 
 

then inside main function:

/* creation of ADXL_Handler */
 
 ADXL_HandlerHandle = osThreadNew(ADXL_Handler_TaskFun, NULL, &ADXL_Handler_attributes);
 
 
 
 /* creation of Clock_Task */
 
 Clock_TaskHandle = osThreadNew(Clock_Task_Fun, NULL, &Clock_Task_attributes);
 
 
 
 osKernelStart();

Could you please tell me What I am supposed to ?

11 REPLIES 11

the code is too long to be posted here so I attach it as a file. due to dependencies between the part of the code I upload the whole code which is the most simple one. although it is long. this code works properly and the line related to task notifications are commented.

What is priority of TIM16 interrupt? Is it higher (smaller number) than the max. allowed interrupt priority for FreeRTOS calls?