cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746G-DISCO Touch Screen using STemWin + SD Card FatFS

dziku
Associate II

Hello,

I started out with this example:

https://community.st.com/s/article/FAQ-Enable-touch-screen-on-the-STM32F746G-Discovery?t=1607121722793&searchQuery

Then I try to add SD Card support using FATFS on SD Card and SDMMC1 (similar to the “STM32Cube_FW_F7_V1.15.0\Projects\STM32746G-Discovery\Applications\FatFs\FatFs_uSD�? example - which I can compile and run on my board, so I know the hardware works and my SD Card is good)

My code fails consistently on step #4 in my "user.c" file, which is when I try to create/open a new file :astonished_face: 

The touchscreen logic runs fine and my error message is displayed on the screed…

Is it something with my clocks configuration?

Is it something with the signals to the card (pull-up vs no-pullup, etc...)?

Is it something with any of the FatFS or driver files (old versions, bugs, etc...)?

Can I not use the SD Card while using the Touch Screen support (that would be crazy...)?

I’m not sure why this is happening, but would appreciate any help you can offer.   

Attached is the .IOC file and the GUI_App.c file where my user function is called from (all generated using STM32CubeMX 4.26.0 and modified using Atollic TrueSTUDIO 9.3.0 + the FatFs_uSD code generated using the same STM32CubeMX 4.26.0)

Please help!!! 😊

Thanks in advance for any assistance you can offer…

3 REPLIES 3

Hello

check if HAL_SD_InitCard(...) function is called during initialization .

dziku
Associate II

thanks for the post!

yes, HAL_SD_InitCard() is called:

HAL_SD_InitCard() at stm32f7xx_hal_sd.c:352 0x80051ba

HAL_SD_Init() at stm32f7xx_hal_sd.c:329 0x800518e

BSP_SD_Init() at bsp_driver_sd.c:81 0x800c2ae

SD_initialize() at sd_diskio.c:146 0x800cb8c

disk_initialize() at diskio.c:100 0x800810c

f_mkfs() at ff.c:5,323 0x8009d48

SD_Card_Init() at user.c:42 0x800d3e8

GRAPHICS_MainTask() at GUI_App.c:65 0x800a832

main() at main.c:153 0x800c4f8

dziku
Associate II

After a few days I solved the problem... It was a bit frustrating, because the "STM32Cube_FW_F7_V1.15.0\Projects\STM32746G-Discovery\Applications\FatFs\FatFs_uSD" worked every time on my STM32F746G-DISCO board with the uSD Card I had inserted, but everything else I tried failed. I watched all the YouTube videos and searched all the forums, but nothing worked. Finally, I decided to take a step back and create a project using the latest CubeIDE 1.5.0 with just the CD Card support, and compare all the applicable code to the example provided by STM in the CubeMX repository STM32Cube_FW_F7_V1.15.0. Everything matched and it still didn't work. So I decided to hook up my trusty logic/protocol analyzer to the SDMMC1 bus (at least the CK, CMD and one of the Data lines). This turned out to be the key to figuring out the problem. What I noticed is that, in the STM example the SDMMC1_CK signal stops toggling periodically, but in my generated code the SDMMC1_CK signal kept toggling continuously. This got me looking at the SDMMC1_CK configuration, but both configurations specify SDMMC hardware flow control = Enabled. Anyway, I decided to change that in my project and Whaaalllaaa!!!!!!!!!!!!!!!!!!!!!!! Now these settings were different, but it worked!!!!!!!!!!!!??????????????????????

STM example - Bus signals capture and SDMMC1 registers:

0693W000006Evz3QAC.jpg 

0693W000006EvytQAC.jpgCubeIDE generated code - Bus signals capture and SDMMC1 registers:

0693W000006Evz8QAC.jpg0693W000006EvzDQAS.jpg 

I got my code to work now, but can someone explain this to me, please? =O

Also, for completeness attached is my project generated from scratch using CubeIDE 1.5.0

If you are interested, or have some insight into why this could be happening, you can build and compare to the STM Example STM32Cube_FW_F7_V1.15.0\Projects\STM32746G-Discovery\Applications\FatFs\FatFs_uSD and let me know why this different code makes a difference!!!! LOL