Skip to main content
chai
Associate II
August 27, 2012
Question

Fatfs SD card on STM32152L-Discovery board

  • August 27, 2012
  • 3 replies
  • 791 views
Posted on August 27, 2012 at 15:40

Hi,

I am working on read,write to a SD card using SPI method on board STM32152L-Discovery board. Now I can create a folder, create a file, and read, write. But when I want to get the capacity of the SD card, no matter I use 1GB SD card or 2 GB SD card, I get DeviceSize 2037672302, CardCapacity 1380012885, CardBlockSize 12628。

Any ideas?

Thank you.
    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    August 27, 2012
    Posted on August 27, 2012 at 17:32

    Sounds like a structure is not being initialized to zero, and status/errors are being ignored.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    chai
    chaiAuthor
    Associate II
    August 27, 2012
    Posted on August 27, 2012 at 17:57

    In that case, how should I do?

    Thank you.

    Tesla DeLorean
    Guru
    August 28, 2012
    Posted on August 28, 2012 at 02:55

    I'd guess I'd start by looking carefully at the code, the flow, and the content of data structures and variables along the way.

    Look at what the tool chain is creating, and if structures are being initialize as expected.

    You could use memset() to get known values into some structures. You'll need to review how you do error propagation, and delve into library code to see why/where things fail with the SD card interface.

    I'm not able to deduce much about your code, or tool chain from the information in the thread.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..