cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 ADC interrupt not invoking when used with FreeRTOS

KBhon.1
Associate III

I am working on a project that requires 3 channels of ADC1 and FreeRTOS.

I am using STM32F446RCT6.

I start ADC conversion at the start of the code

HAL_ADC_Start_IT(&hadc1);

Here is my implementation for ADC callback.

whereas array to hold data is described as:

volatile uint16_t ADC_raw[3] = {0};

void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
{
	if (__HAL_ADC_GET_FLAG(hadc, ADC_FLAG_EOC))    //if call to end of convesion
	{
		ADC_raw[counter] = HAL_ADC_GetValue(hadc);    //ADC value stores in array
		counter++;
		if(counter>2) counter = 0;
	}
 
}

Now,

When I do not implement RTOS and just runs normal code in while(1) loop, it works well and values for ADC_raw is updated correctly.

But when I enable RTOS and run the same code, the ADC callback is never getting called and thus ADC_raw values are always zero.

I can't figure out what can be the issue. Any help would be greatly appreciated.

Here is my configuration for ADC, interrupt is enabled, DMA is not used.

 0693W000007E5MhQAK.pngHere is my RTOS initialization:

 0693W000007E5MwQAK.png0693W000007E5NLQA0.png

1 REPLY 1

Hello @Community member​ ,

Can you share your project that uses FreeRTOS for further check?

Thanks in advance.

Walid.