cancel
Showing results for 
Search instead for 
Did you mean: 

Fatfs SD card on STM32152L-Discovery board

chai
Associate II
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.
3 REPLIES 3
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 Venmo
Up vote any posts that you find helpful, it shows what's working..
chai
Associate II
Posted on August 27, 2012 at 17:57

In that case, how should I do?

Thank you.

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 Venmo
Up vote any posts that you find helpful, it shows what's working..