2016-10-29 01:41 AM
Hi,
I'm trying to use CubeMX to work with the SD through SPI. In the search of this forum I found a lot of answers on how to work with SD for SPI. Unfortunately I do not find them useful. It would be ideal to find an example of implementation user_defined.c, user_defined.h. If everything is so obvious why I have never seen simple example of implementation? I use STM32L151, therefore do not offer SDIO.Is/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/user_diskio.c%20and%20diskio.c&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=275
code correct? #no-hablo-hal #spi-sd-cubemx-hal-fatfs-stm32l1x2016-10-29 09:45 AM
There is a reason a lot of us don't use HAL/CubeMX nor support it here...
There seems to be an endless parade of people having problems with SD Cards using SPI/SDIO. It is a complicated protocol, and a lot of people have zero competence in the mass storage and file system space, so if it doesn't work out-of-the-box it is going to be very hard to fix/debug. I would not trust the code provided by h.rick, he copied it from someone else, it didn't work for him, and he didn't have the skills to fix it.2016-10-29 09:56 AM
One of dozens of threads started on the topic.
[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/SD%20can%27t%20read%20write&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/AllItems.aspx¤tviews=17]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fSTM32Java%2fSD%20can%27t%20read%20write&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&TopicsView=https%3A%2F%2Fmy%2Est%2Ecom%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Java%2FAllItems%2Easpx¤tviews=17 You'd also want to look at the code and SPI connectivity you have on the board now. Is the connector wired up properly? Can you review the data with a scope or analyzer? Are you getting reasonable responses via SPI and the card? There are a whole array of reasons why things fail, and it's hard to guess the specific reason from the level of information provided.2016-11-09 04:25 AM
2016-11-09 09:26 PM
For the Nucleo-F091rc and the Adafruit shield ID802 exist inside the CubeMX code examples from Adafruit how to use SDcards with SPI.
See UM1787 / en.DM00122017.pdf for more details. https://www.adafruit.com/products/802 Did not try it by myself, because the Adafruit shield is somehow expensive and the display is really small. But for the SDcard it may be a solution. Using SDcards with SDIO / SDMMC with CubeMX is very easy (with Nucleo-144 STM32F746) so i did not spend any time for the SPI mode. Best regards, Markus.