cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L152D SD Card Problem

CS Kim
Associate II
Posted on November 09, 2017 at 11:19

I'm having a problem on data logging.

I use Chan's FatFs R0.08a, SDIO 1 bit mode, DMA and ST standard library, IAR compiler.

I save 600,000 data per 200ms in SD Card using CSV format. It need about 33hours.

If I try 3 sets, 1 set is good for 600,000 data, but 1set have broken 7 data, and 1set have broken 17 data.

I tried it several times. It have Max 20 broken data. Are there anyone have similar experience?

My code brief flowchart is as below.

* every 12second for 60 data (200ms * 60 = 12sec)

1. set External 4MHz

2. f_mount(0, &fs)

3. res = f_open(&F, fileLName, FA_WRITE);

4. res = f_lseek(&F, end_no);

5.  __disable_irq();

    res = f_write(&F, wbuff, cnt, &BytesWrite);    //wbuff[] : 60 Data = about 2000 characters

    __enable_irq();

6. f_close(&F);

7. res = f_open(&F, fileLName, FA_READ);

8. res = f_lseek(&F, start_no);

9. res = f_read(&F, rSDRead, cnt, &BytesRead);

10. Verify each character

11. f_close(&F);

12. SD_PowerOFF();

13. Set Internal 4.194MHz for Battery Save

Of course I tried above flow in many many ways .

It is not easy and need long time for 1 test.

I would be so grateful if anyone could help me.

2 REPLIES 2
Andrew Neil
Evangelist III
Posted on November 09, 2017 at 11:59

What, exactly, do you mean by 'broken data' ?

CS Kim
Associate II
Posted on November 09, 2017 at 12:16

Thanks so much.

Sorry, My english is very poor.

Broken data is not normal data.

Ex. I write '12000,ACV,3.0000,V,LF,' but in Excel, I can see '500000,DCV,4.1200,V,LF,'.

      Maybe it is data in before file. It did not overwrite.

      Sometimes, I can see strange characters. Max 20 data among 600,000data do not write normally.

      I write and read and verify. But I don't know why didn't check it.