2013-01-02 08:56 PM
Hi,
I have an STM32F4 discovery board and I want to access SD card via SPI. The reason why I want to access Sd card via SPI is that the breakout module that I have has an SPI interface. I have looked on the internet but have only found examples which are accessing SD card using the SDIO interface. Is there any way that I can get some example code for reading SD card via SPI or some wiring alternative to convert the SPI interface to SDIO interface so that I can use the available examples. This is the module that I have http://www.aliexpress.com/store/product/SD-Card-Reader-Module-for-Arduino-ARM-Read-and-Write-Free-shipping/316774_526750081.html Regards #spi-sd-card-stm32-discovery #stm32f4-discovery #choose-appropriate-parts #spi2013-01-03 02:27 AM
''I have looked on the internet but have only found examples which are accessing SD card using the SDIO interface''
I don't believe you! The internet has many, many examples of using SD Cards with microcontrollers via SPI: http://www.lmgtfy.com?q=SD+Card+microcontroller+SPI''Is there any way that I can get some example code for reading SD card via SPI'' Yes! See above.
2013-01-03 02:34 AM
''The reason why I want to access Sd card via SPI is that the breakout module that I have has an SPI interface''
So why don't you just get a breakout module that provides the full SD interface?! eg:
2013-01-03 05:43 AM
I think others have asked similar questions here in the past, SPI is a fairly common implementation vector, and as Andy notes there should be plenty of examples out there. These might well take additional effort to port to your specific chip/board/tool-chain, but the core code might prove instructive.
ST has some examples in their firmware libraries, for other parts/boards, but you'll have to port them to your specific requirements. STM32L1xx_StdPeriph_Lib_V1.1.1\Utilities\STM32_EVAL\STM32L152_EVAL\stm32l152_eval_spi_sd.c2013-01-03 08:41 AM
Hi,
Well I think I didnt made my self clear the first time. I know that there are many examples available for SD Card via SPI for other microcontrollers but I was looking for some example code for STM32F4 microcontroller family. I have been looking at the example codes for other microcontrollers (PIC18 and Arduino). The PIC18 code was helpful to me but I was looking for some code which would save me time for porting that code to the STM32 code. Thats why I asked for some example. I will look into the example code as suggested by clive1. ''So why don't you just get a breakout module that provides the full SD interface?!'' Well because that module is not available in my area and getting it to ship from somewhere else will probably take 10 days which is too long time. Regards2013-01-03 08:54 AM
The only thing which is actually specific to the STM32 is the low-level SPI control - you should be able to work that out from the ''generic'' SPI examples from ST...
2013-01-03 11:43 AM
No, I think you were reasonably clear, however the dearth of SPI examples for the F2 and F4 platforms stems from the fact everyone is using SDIO due to the speed and obsolesce of pretty much anything below 2GB on SD Cards. The vast majority of professional use of the platform is likely to be with the MicroSDHC cards with capacities up to at least 64GB.
I could port the SPI implementation, but there are no economic drivers for me.