3
votes

I'm starting to work with a stm32l0 board and it was fine until I had some more interesting functions to use. I never read SD card out of windows, I found Pins links and started to read about SPI which could be a suitable solution for our prject (I think).

But the issue is in the programming part, every tutorial I find skips basics. I uses STM32CubeMX to generate code with HAL and FATFS but I don't know how to initialize and then use my SD card. I try to paste code I find but I can't debug it then and there is no point just pasting someone's code.

Thanks and sorry for my grammar,

EDIT : I came here after this post : link I'm now trying to access a SDcard with a stm32l0 controller. I've been advised to use FATFS to read the device but what I understood is that the library needs a way to access the data : SPI. I selected FATFS and SPI2 in STM32CubeMX and imported the project in Eclipse (I'm using HAL and the SW4STM32). On the pin description I saw MISO,CK,MOSI in CubeMX which were on pins PB12,PB13,PB14. But in the main file those pins are never used.
Another thing affraid me in the post I mentionned : the SDcard needs to be initialized in a way a never heard of.
I don't know if you need to have the SPI_Init and GPIO_Init functions, I will edit this message if you need it.
I will edit anyway in the morning because the post must be so confuzed, my brain is burning up i'm sorry. Ask if you need precision on whatever. Thanks !

2
Welcome to Stack Overflow! Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.Joe C
Sorry I didn't know. I posted here because I found a similar problem here but the author looked like he managed to do a lot of things that might help me before being stuck. I'll find the subject and post it just after !Blaitox

2 Answers

2
votes

If you use CubeMx and configure SPI to access SD card, the pins are automatically configured in your code. Look at the definitions/implementations of the first few functions in your generated main.c.

If you do not have any experience in STM32 and its HAL drivers, first try to understand how the things stack up.

The quickest way to do that is to try an example.

All your CubeMx Firmware libraries are located at

C:/Users/UserName/STM32Cube/Repository/STM32Cube_FW_XX

Go to Projects>Examples folder (may not be exact - but paths are similar) and you will find the examples.

0
votes

For others facing this issue, just select user defined in CubeMX and use kiwih's drivers. They are very good and well documented!

https://github.com/kiwih/cubemx-mmc-sd-card