Managing DMA Callback and FreeRTOS Tasks with Timing Constraints on STM32f4

My current project involves constantly receiving digital samples through DMA on an STM32f4 and performing DSP in the complete callback interrupt triggered after each sample. However, frequent callbacks are hindering freeRTOS from running other tasks while DMA waits for completion. My objective is to allow freeRTOS tasks to run every 6ms following a completed DMA callback. Initially, I thought about disabling interrupts using __disable_irq() in the complete callback and re-enabling them with __enable_irq(), but considering my high-priority button interrupt was still active—and not knowing whether this technique could guarantee exactly 6ms—I tried another approach of only deactivating the specific DMA interrupt by utilizing __set_BASEPRI(priority << (8 - __NVIC_PRIO_BITS)). I then started a timer that runs at intervals of 6ms before restoring normal function via calling back with_ _set_BASEPRI(0) upon elapsed period time completing successfully executed timed actions—nonetheless,it did not work since it kept switching between both types of call-backs without allowing freertos tum to operate independently. I would greatly appreciate any feedback or advice. Thanks 🙏🏽
Solution:
Adjusting the timing might help yeah , but it's more about ensuring the callbacks don’t hog all the CPU time. By using double buffering or adjusting interrupt priorities, you’re already reducing the time DMA interrupts take. If FreeRTOS still isn’t getting enough time, you might also consider tweaking task priorities or adding some delay within the callback if possible…
Jump to solution
4 Replies
Camila_99$$
Camila_99$$3mo ago
Hii @Sterling One thing that might help is setting up a DMA double buffer so you can process data in the background while the next set of samples is being captured. This could reduce the need for frequent callbacks and give FreeRTOS more breathing room
Camila_99$$
Camila_99$$3mo ago
Another approach might be using a lower-priority interrupt for the DMA, so it doesn’t block other tasks completely.
Sterling
Sterling3mo ago
Thanks @Camila_99$$ , but would I need to adjust the timing of the callbacks to allow freeRTOS tasks to run ??
Solution
Camila_99$$
Camila_99$$3mo ago
Adjusting the timing might help yeah , but it's more about ensuring the callbacks don’t hog all the CPU time. By using double buffering or adjusting interrupt priorities, you’re already reducing the time DMA interrupts take. If FreeRTOS still isn’t getting enough time, you might also consider tweaking task priorities or adding some delay within the callback if possible…
Want results from more Discord servers?
Add your server