element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
STM32F4DISCOVERY Expansion Boards
  • Products
  • Dev Tools
  • STM32F4DISCOVERY Expansion Boards
  • More
  • Cancel
STM32F4DISCOVERY Expansion Boards
Forum STM32F4 Discovery - problem interfacing SD card
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join STM32F4DISCOVERY Expansion Boards to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 3 replies
  • Subscribers 6 subscribers
  • Views 1990 views
  • Users 0 members are here
Related

STM32F4 Discovery - problem interfacing SD card

Former Member
Former Member over 10 years ago

Greetings all,

 

I am trying to make STM32F4 (on STM32F4 Discovery board) write a text file on an SD card, but with no success at all. I have tried this example by clive1 (flashing with hex/bin file directly). And also I have tried both, SPI and SDIO examples from this site. In the project from second example I placed "debugging" LED after the line: if (f_mount(&FatFs, "0:", 1) == FR_OK) And it seems the if condition isn't met, because LEDs don't turn on. Program ends in while(1) loop.

 

I believe my wiring is ok and also I am using new Micro SD card (tried also SD with SPI), but no success. Does anyone have any suggestions, please, how I could resolve the problem?

 

Thank you and kind regards,

JC

  • Sign in to reply
  • Cancel
  • michaelkellett
    michaelkellett over 10 years ago

    What tools are you using to download and debug code ?

    I think the Discovery board debugging hardware is supported by the Keil tools which have good debugging capabilities.

    If you can try to run your code in that environment you might be able to find the problem.

    Do you have access to a scope ?

     

    (It's very common that this sort of thing fails because the hardware isn't connected correctly or the IO pins are not configured correctly -  with the debugger and the scope you can resolve those issues quite quickly.)

     

    MK

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to michaelkellett

    Thank you for your reply. I am using CooCox CoIDE with ST-Link connection. It has debugging capabilities too, but I don't know how they compare to those of Keil.

    I don't have access to a scope presently, but it might happen sometime soon. What signals should I be testing with scope in my case, and what are they expected to be like?

     

    Chances are hardware isn't wired properly, but I did my best to follow the instructions/schematics for examples. The four data and clock connections in the SDIO sample are about 2cm (< 1 inch) in length. And SPI connection is quite hard to mess up with the module I have. Also, the example from the ST forum also contained a hex/bin file, which I downloaded to the MCU, so configuration should be alright.

     

    Best,

    JC

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • michaelkellett
    michaelkellett over 10 years ago in reply to Former Member

    If you are downloading a hex file you don't have a chance of debugging.

     

    Unless the code you are using is too big for the 32k limit on the free version then download the free Keil tools (they can use the ST link)

     

    Use them to compile the source code.

     

    Read the help about the debugger and then check the following:

     

    Using the system viewer - is the peripheral (SDIO controller or SPI ) properly configured .

    Is the GPIO correctly set up for the pins you are using.

    Follow the code and see (if you can) where it goes wrong.

    If you have a DMM you can check that the pins on your SD card socket wiggle when you stimulate them from the debugger (you might need to halt the code and temporarily swap the GPIO configuration to normal GPIO to do this.)

    In order to debug this kind of thing you need to understand  how all the different parts work and have a tool that lets you look at  them.

     

    If you want to know what signals to expect on the SD card then you need to:

    1) Read the card spec (the free version will be adequate)

    2) Read the peripheral spec in the St reference manual

    3) Do some Googling and read a load more stuff to get some ideas.

    4) Check what your code is trying to do - is it using SPI or 4 bit SD card mode  - possible write some simple test functions to wiggle the pins or poke the peripheral directly.

     

    MK

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube