cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 SDIO - SD/4bits mode

campbiel
Associate II
Posted on March 27, 2014 at 14:55

Hi!

Does someone use the SDIO module on STM32, especially in 4 bits mode, through DMA? Standard 1 bit SPI was good for small project and tiny UC but is quite slow compared to the latest STM32F42x performances.

#sdio-sd-fatfs
8 REPLIES 8
stm322399
Senior
Posted on March 27, 2014 at 15:21

I do. I have SDIO 4b + DMA running with FatFs.

For sure it helps in performance.

However I observed that the sector write can be slower than the transfer itself (well it certainly depends the SDcard itself). In such a case the gain of 4b vs 1b is not high.

Posted on March 28, 2014 at 04:00

Yes, and it's very rapid.

I've got SDHC cards reading at 10.6 MBps using nominal clocks, and 15.8 MBps with aggressive clocks.

Sandisk Extreme MicroSD Card, 32 MB read as 32 KB blocks. STM32F4-Discovery + STM32F4-DIS-BB

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
shivangbaveja
Associate II
Posted on May 07, 2015 at 15:40

Hey Gonzalez

I have a working code which writes about 300 bytes of data at 50 Hz to SD card. This uses SDIO interface without the DMA. But the problem with this code is that it causes the code to slow down at times. So, I have two questions:

1. Will it increase the speed if I use DMA with SDIO interface.

2. What is the Max data I can write at 50 Hz, without slowing the code down. I have stm32f103 series mcu.

 

Thanks

Posted on May 07, 2015 at 20:15

Appears to be somewhat off topic.

Sounds like you need to buffer the data more effectively, and have the writing code in it's own thread so it doesn't block your other activity.

Writing 300 bytes is perhaps one of the worst sizes, it doesn't even fill a single 512 byte sectors, let alone a cluster or two.

I don't have any F1 parts/boards supporting SDIO to hand, but I'd suspect 1-2 MBps sustain writes, what's that 20KB at 50Hz

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
shivangbaveja
Associate II
Posted on May 08, 2015 at 09:30

How much data should I buffer so that the rate at which my other code is running is not affected?

I have not implemented RTOS right now. So, the whole code is running on a single thread, which gets affected by this logging.

Is there anything else I can do in terms of implementation. I can only use SDIO interface right now for writing to SD card. Should I consider buying a new board which has SPI interface for interfacing the SD card.

Posted on May 08, 2015 at 13:59

You don't need to use an RTOS to effectively use interrupts and buffering. You need to get out of your serial execution with blocking mindset.

SPI will be significantly slower than SDIO

I'd try to write as blocks of 16KB or 32KB, something that's an integer number of sectors, on a sector boundary.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
shivangbaveja
Associate II
Posted on May 12, 2015 at 07:41

But the amount of data buffering I can do before writing to SD card is limited by the RAM size. 

I think implementing DMA with a queue data structure for holding data would solve the problem. Is it possible to implement queue such that as soon as queue is full, an interrupt is generated which initiates the DMA transfer.

Posted on May 12, 2015 at 15:03

Ok, so benchmark what's workable in your system.

I'd probably do the 50 Hz stuff under interrupt. There are lots of ways to solve this, use your experience/training to pick one that works for you.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..