cancel
Showing results for 
Search instead for 
Did you mean: 

FatFs/SDIO on STM32L1xx

esazonov
Associate II
Posted on February 28, 2015 at 00:17

I am having problems with the SDIO interface on STM32L1 series of processors.

The SDIO option is available on the STM32L152D-EVAL, but the price of this board is rather high, so I am working with a modified Nucleo board. The SDIO option is not available on the Nucleo board (Nucleo-L152RE), however, I replaced the stock STM32L152RE with STM32L151RD which has an SDIO. I wired the SD card the same way as it is wired in L152D-EVAL, modified the sample IAR project with FatFS example for STM32L152D-EVAL to change the target (the project is attached) and ran the code.

The interface “sort of�? works. My code will attempt 10000 writes, each 512 bytes, to the card, but will crash anywhere between 1 and 5000 writes. It always crashes with error code FR_DISK_ERR that is thrown by ABORT in fs_write:

#if _FS_TINY

         

if (fp->fptr >= fp->fsize) {

              

/* Avoid silly cache filling at growing edge */

          if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR);

          fp->fs->winsect = sect;

                                            

}

#else

         

if (fp->dsect != sect) {

                    

/* Fill sector cache with file data */

         

if (fp->fptr < fp->fsize &&disk_read(fp->fs->drv, fp->buf.d8, sect, 1))

              

    ABORT(fp->fs, FR_DISK_ERR);

                                            

}

#endif

The results is that the file is created and will have several lines written, but never the full 10000 lines.

In addition, 4-bit SDIO refuses to work on any card (tried 5 different cards 1Gb – 8Gb). To see if my soldering skills are to blame, I made another L151RD board and the behavior is identical. Any pointers on getting the SDIO to work properly, complete the writes and work with the 4-bit interface? Am I missing something obvious?

0690X00000603FsQAI.jpg

0690X00000603JUQAY.jpg

10 REPLIES 10
esazonov
Associate II
Posted on March 05, 2015 at 22:51

Thank you, clive!

I was able to solve the mystery of the crashing HAL SDIO code posted earlier. The reason was in HAL timer ticks. Inserting “

 

HAL_SuspendTick();� allowed for the code to complete every time it was run. The HAL benchmarked at 280Kb/s in 512 and 1024 – byte writes.

The project you posted runs perfectly. The code benchmarks at 295Kb/s in 512-byte writes and 1.8Mb/s in 8192-byte writes.

The project did not load into coIDE 1.7.8.