AnsweredAssumed Answered

STM32L152D SD Card Problem

Question asked by CS Kim on Nov 9, 2017
Latest reply on Nov 9, 2017 by CS Kim

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

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.