cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in writing SD card

freya17365
Associate II

Hi to all,

I am not sure this is the correct forum, but I do not know where to put the question elsewhere.

I need to interface with an SD card using SPI interface and I'm experiencing a big issue in write operation (CMD 24) because things quite always go wrong.

The write routiner is the following:

1) CS goes low

2) Send CMD 24 command

3) Check if response is 0x00. If not repeat point 2 and 3 for 30 times (my arbitrary timeout)

4) if response continue not beeing 0x00 return with error

5) Send 0xFE (start token)

6) transfer 512 bytes

7) transfer 0x00 and 0x00 (CRC)

😎 Read Response

9) Send 0xA0 while return from SD is not 0x00, or timeout (3000 times)

10) CS gose high

My program does the following:

A) Write sector 814 (FAT1)

B) Write sector 8599 (FAT2)

C) Write sector 16384 (ROOT DIRECTORY)

D) Write sector 16440 (First file sector)

D) Write sector 16441 (Second file sector)

..........................

In annex I enclose the response, but usually, after 3-4 write cycle the SD Card always replay with 0x01 (idle state) and won't recovery.

As I should acquire data for days, I need a reliable routine. How can I solve the problem?

Thank you

Freya

0 REPLIES 0