cancel
Showing results for 
Search instead for 
Did you mean: 

HAL DMA Complete callback execution context?

engineering
Associate II
Posted on December 03, 2015 at 15:48

Maybe I'm blind but I couldn't find this info anywhere.

When I get a HAL ''DMA Complete'' callback, is that code operating inside an ISR context or as normal user code?  I inherited some firmware code and it's doing a huge pile of work in the callback and I need to know if this could cause the locking out of other interrupts and user code.

All info appreciated!

Ed Averill

#stm32 #hal #callback
2 REPLIES 2
Posted on December 03, 2015 at 16:34

I'd expect it's done under interrupt context.

As I understand it, you call into the HAL from your IRQHandlers, it manages that based on the handle for the peripheral passed in, and then it calls back out to the registered callback functions supplied.

There is a lot in this that is broken, or prone to fail, especially if you have delays or timeouts dependent on the SysTick / HAL_Delay() methodology, which should really be using a free running hardware clock.

So assume always that your code may be running under interrupt, and that malloc/free, and other things which are inherently not thread safe, do not run concurrently.

How this manifests in the FreeRTOS builds, I don't know, but callbacks/interrupts should do very brief actions and LEAVE. The real work needs to be handled by Worker Threads/Tasks, or other deferred actions.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
engineering
Associate II
Posted on December 03, 2015 at 16:42

Ugh, that's kind of what I suspected.  Inside the callback the code is performing a massive number of floating-point operations on about 64K worth of numeric data, filtering/normalization and the like.. I was seeing wildly varying timings in the external user code, which is why I suspected the callback was in an interrupt context.

Time to refactor.. and THANKS for the response!

..ed..