STM32L4 FreeRTOS+DMA2 Channel 4 problem
I am using STM32L496 Nucelo, CubeMX 6.1.1; FATFS, DMA SDMMC with FreeRtos. For some reason I have problems when it comes to using DMA2 Channel 4 with FreeRtos.
When it is selected for SDMMC1_TX then I can mount SD card and read data without any problems. Although I can't write any data into SD card. I call:
fresult = f_open(&fit_record_file, "test.txt", FA_CREATE_ALWAYS | FA_WRITE);
Which return FR_OK but the file is not created. Next when I call:
fresult = f_write(&fit_record_file, &data_crc, sizeof(data_crc), &fit_record_br);
Program gets stucks for SD_TIMEOUT in function SD_read at status = osMessageQueueGet(SDQueueID, (void *)&event, NULL, SD_TIMEOUT); in sd_discio.c at 463 line. Callback BSP_SD_WriteCpltCallback is never called.
When DMA2 Channel 4 is selected for SDMMC1_RX then I can't mount SD and at the end program again waits SD_TIMEOUT for message, which never comes. Callback BSP_SD_ReadCpltCallback is never called.
After this tests it looks like there is a problem with DMA2 Channel 4, but I turned off FreeRtos and everything works fine no matter how DMA2 is configured.
Has anyone met this problem? Maybe you have any sugestions where might be the problem?
EDIT: Problem is not related with FreeRTOS.
After turning off FreeRTOS, DMA template was turned off by CubeMX so I was making tests without DMA usage.
Now when I turned on DMA template and made tests without FreeRTOS problem still occurs.
- Turning DMA2 Channel 4 on RX crashes reading
- Turning DMA2 Channel 4 on TX crashes writing
So problem is related only with SDMMC DMA and FATFS - using DMA2 Channel 4 creates BUG. Without DMA everything works fine.
