cancel
Showing results for 
Search instead for 
Did you mean: 

Weird relationship between TouchGFX, FreeRTOS and SDIO/DMA

feliperibas
Associate II

I am experiencing quite a weird behavior on my STM32F429I-DISCOVERY board when trying to use SDIO module:

 

If I use SDIO (1 wire) without DMA, it works fine, writes and reads. Also works in combination with my main application (TouchGFX, ADCs+DMA, 1 FreeRTOS task - besides TouchGFX and USBH task, USB OTG Host). However, if i configure my SDIO to work with DMA2 (Stream3 (TX) - Stream6 (RX)), it does write what i want, but it fails to trigger the DMA Interrupt at the end, leading to a DMA Error Flag being set and no Interrupt at end of transmission being triggered.

So I've created a test-code right after all MX_...Init(); initialization functions, but before osKernelInitialize() and also before FreeRTOS task even get created. Same behavior: SDIO works, SDIO+DMA doesnt. Then, it comes the surprise: if I comment MX_TouchGFX_Init();, then it does work. I thought it could be some timing issue or configuration being messed up, but changing orders didnt solve.

Then I realize the following: changing NVIC_SetPriority() from my DMA2_Streams and from SDIO from 5 to 4, also solved. But this shouldnt be done, as my configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY is 5. CubeMX wont even allow me to set those priorities to 4, but doing it manually at the code for testing purpose (since everything is running before OS), did solve the issue. 

Now what is even weirder: if I leave these priorities at 5, but change all others from 5 to 6, does NOT solve the problem (I thought it could be a conflict with DMA2D, FMC or any other peripheral). Then I realized: having everything back to default priorities from CubeMX (5), but only changing configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY from 5 to 6, also seems to fix. I even ran a complete diff on the project between working version and non-working version and the only difference is really configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY. 

This does not make any sense at all in my head, because FreeRTOS is not even running yet. However, having SDIO and DMA2 streams with their normal priority at 5 and only raising configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY from 5 to 6, did make my SDIO+DMA work.

So the question is: how does configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY  affect MX_TouchGFX_Init()? Analyzing this function i come down to "HAL::initialize();" which seems to be a call to pre-compiled STM32 libraries, which i dont have the source code. But it does seem very non-intuitive that a FreeRTOS config is affecting my code even before OS is running. Any tips on what could be the reason on that and what would be the best clean solution for it?

0 REPLIES 0