cancel
Showing results for 
Search instead for 
Did you mean: 

ADC DMA continuous mode stops FreeRTOS task.

JChen.24
Associate III

Hi,

I am using STM32F746 discovery board. I enabled FreeRTOS task and it is running fine. After I start ADC DMA function by enabling DMA continuous request mode and calling HAL_ADC_Start_DMA(), the RTOS task stops running. The ADC conversion stops the RTOS task. I try to make FreeRTOS task priority lower than the DMA, so I set:

osThreadDef(ModbusTask, ModbusTask_init, osPriorityRealtime, 0, 512);

HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 15, 0);

But RTOS task still not running. What is the NVIC priority level of the RTOS task? The osPriorityRealtime is 3, not between 5 to 15 priority level.

5 REPLIES 5
Tom Schrauf
Associate II

I have no experience neither with HAL functions nor with freeRTOS but did you enable ADC or DMA completion interrupt and not provide an ISR ? Imo this has got nothing to do with interrupt priorities. Also a higher priority number will result in a lower priority - 0 being the highest.

JChen.24
Associate III

Thanks for the comments. I setup the DMA interrupts and ISR already. The ADC can get the correct readings each time.

TDK
Guru

If DMA interrupts come in faster than the MCU can handle, it'll spend forever handling those.

Are you converting samples quickly to a small buffer in circular mode? Perhaps do a calculation of the expected frequency the ISR will be called to ensure it doesn't swamp the system.

If you feel a post has answered your question, please click "Accept as Solution".
JChen.24
Associate III

Thanks for the good suggestions. I make the buffer bigger to slow the DMA interrupt and it works fine now.

Piranha
Chief II

> What is the NVIC priority level of the RTOS task?

Those two are totally different and unrelated. NVIC is a hardware feature which manages interrupt processing by the CPU. RTOS priorities are priorities of software threads/tasks executed by RTOS kernel in a basic thread (non-interrupt) mode. NVIC is used even in projects without RTOS. :)