2015-12-03 06:48 AM
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 #callback2015-12-03 07:34 AM
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.2015-12-03 07:42 AM
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..