STM32- RTOS -Task Notify From ISR

795 Views Asked by At

I want to notify my task to run from an ISR. I red the RTOS docs but I could not do it. I would really appreciate if you tell me what I am supposed to do and give an example if it is possible. I used cmsis-V2. Inside the ISR which I am sure the ISR works correctly I wrote:

  void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
  /* USER CODE BEGIN Callback 0 */

  /* USER CODE END Callback 0 */
  if (htim->Instance == TIM15) {
    HAL_IncTick();
  }
  /* USER CODE BEGIN Callback 1 */
  if (htim == &htim16)
    {
        BaseType_t xHigherPriorityTaskWoken;
        xHigherPriorityTaskWoken = pdFALSE;
        vTaskNotifyGiveFromISR(ADXL_HandlerHandle , &xHigherPriorityTaskWoken);
        portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
      }

  /* USER CODE END Callback 1 */
}

I also used systick timer for FREE RTOS and timer 15 as the system timer . is it possible that the problem is related to this part ? I dout because task_notify_give function only add up and is not a blocking mechanism like semaphore.

and inside the thask, inside the for loop the first lines are:

ulNotifiedValue = ulTaskNotifyTake( pdFALSE, portMAX_DELAY);
      if( ulNotifiedValue > 0 ){
//my codes ....
}

before for loop I defined:

uint32_t ulNotifiedValue;

but the task is not executed. even once. I use Nucleo H755ZIQ.

before the definition of global variable, tasks are defined like this:

/* 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
};

then inside the main function initializing the schduler is as follows :

 osKernelInitialize();
 ADXL_HandlerHandle = osThreadNew(ADXL_Handler_TaskFun, NULL, &ADXL_Handler_attributes);
osKernelStart();

Then the timers will be started:

 HAL_TIM_Base_Start_IT(&htim16);
 

In CMSIS there is no such a thing like task notification, I took a short look. The functions I used inside the ISR routine are from FreeRTOS. will not there a contradiction? should I use only Free RTOS task create function instead of CMSIS functions?

Thanks in advance.

0

There are 0 best solutions below