Skip to main content
JChen.24
Associate III
December 27, 2021
Question

ADC DMA continuous mode stops FreeRTOS task.

  • December 27, 2021
  • 5 replies
  • 2320 views

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.

This topic has been closed for replies.

5 replies

Tom Schrauf
Associate II
December 27, 2021

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
JChen.24Author
Associate III
December 27, 2021

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

TDK
December 27, 2021

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
JChen.24Author
Associate III
December 28, 2021

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

Piranha
Principal III
December 29, 2021

> 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. :)