2021-12-27 11:56 AM
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.
2021-12-27 12:39 PM
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.
2021-12-27 12:44 PM
Thanks for the comments. I setup the DMA interrupts and ISR already. The ADC can get the correct readings each time.
2021-12-27 01:12 PM
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.
2021-12-27 07:13 PM
Thanks for the good suggestions. I make the buffer bigger to slow the DMA interrupt and it works fine now.
2021-12-29 12:19 PM
> 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. 🙂