Hi all. I’m new to the forum so I don’t know if this is the right category in which to post my question.
I’m new to FreeRTOS and I want to make a project in which I use the xTaskNotifyFromISR & xTaskNotifyWait API. I want to start an ADC conversion after pressing a button. I created an ADC Task with the highest priority that starts the ADC conversion when it gets the nofitication from an EXTI IRQ handler. In the project I have other tasks with lower priorites (a LED task, one for an OLED display and a default task just so the sake of it).
After the ADC task starts the conversion I get on the debug printf output only the ADC value and the other tasks are not running.
This is the ADC task:
void StartADCTask(void argument)
{
/ USER CODE BEGIN StartADCTask /
uint32_t ulNotifiedValueADCTask;
/ Infinite loop */
for( ;; )
{xTaskNotifyWait( 0U, 0U, &ulNotifiedValueADCTask, portMAX_DELAY ); /* Block indefinitely. */ if(ulNotifiedValueADCTask == 1U) { printf("ADC Task\r\n"); HAL_ADC_Start_DMA(&hadc1, (uint32_t *)&adc1_dma_data, sizeof(adc1_dma_data)); } if(ulNotifiedValueADCTask == 0U) { HAL_ADC_Stop_DMA(&hadc1); printf("ADC stopped\r\n"); } osDelay(1000);
}
/* USER CODE END StartADCTask */
}
Blockquote
EXTI handler for the button push:
void EXTI0_IRQHandler(void)
{
/* USER CODE BEGIN EXTI0_IRQn 0 */BaseType_t xHigherPriorityTaskWoken = pdFALSE;
flag = flag ^ 1U;
xTaskNotifyFromISR(ADCTaskHandle, flag, eSetValueWithOverwrite, &xHigherPriorityTaskWoken );portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
/* USER CODE END EXTI0_IRQn 0 /
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
/ USER CODE BEGIN EXTI0_IRQn 1 *//* USER CODE END EXTI0_IRQn 1 */
}
And I’m using the callback when the conversion is finished just to output the value:
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) {
printf(“Conversion complete. Conversion value %u.\r\n”, adc1_dma_data);
}
I’m using Keil IDE and STMCubeMx.
What should I do/change so that after an ADC conversion the other tasks run as well?