3 years, 9 months ago.

How to make a text file on sd card

PIN define 1.SD_D2(PC10) 2.SD_D3(PC11) 3.SD_CMD(PD2) 4.VDD 5.SD_CLK(PC12) 6.GND 7.SD_D0(PC8) 8.SD_D1(PC9)

Using DEMO code "SDFileSystm_HelloWorld"

include file

/media/uploads/benchen0955/1.png

compile result

/media/uploads/benchen0955/2.png

How to solve it???

If I don't like the text file,how to del it(I know the file name)??

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F401RET6 microcontroller.

2 Answers

3 years, 9 months ago.

never forget that the pin names are defined differently for different processors, never use a sample program without checking the pinout
to remove a file look at http://www.cplusplus.com/reference/cstdio/remove/

Accepted Answer
3 years, 9 months ago.

The error message is pretty clear to me: p5, p6, p7 , p8 are not defined! You should replace them with correct pin names in order to make it work!

SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name)
  • The pin defines you have selected are for the SDIO peripheral which is not supported by this SDFileSystem libray. This library uses the SPI, so you should connect your SD card to some SPI pins in order to use this library.
  1. SD_D2 (NC)
  2. SD_D3 (CD)
  3. SD_CMD(MOSI)
  4. VDD
  5. SD_CLK (CLK)
  6. GND
  7. SD_D0 (MISO)
  8. SD_D1 (NC)
  • for example you could connect it to SPI1:
  1. SD_D2 (NC)
  2. SD_D3 (Any_Pin)
  3. SD_CMD (PA_7)
  4. VDD
  5. SD_CLK (PA_5)
  6. GND
  7. SD_D0 (PA_6)
  8. SD_D1(NC)

and then call

SDFileSystem(PA_7, PA_6, PA_5, Any_Pin,"sd") 

You can choose any pin you want for CS.
Look at the Nucleo pinout for other SPI options