News:

Let's find out together what makes a PIC Tick!

Main Menu

MicroSDHC Fat32 Write Speed

Started by Wimax, Nov 27, 2022, 03:56 PM

Previous topic - Next topic

Wimax

Hello  ;D

I am carrying out some write tests with SDHC class 4 and class 10, but the results are quite frustrating and just to know whether it is a problem with my hardware or not...which is the maximum write speed to a MicroSDHC achievable, and actually achieved, with PIC24/DS33 and Positron16 MCUs via SPI bus ?


normnet

#1
As I remember Les has said on some of the faster 16 bit PICs bit banging SPI is faster than the hardware SPI.

I did look into the 4 bit mode SD card protocol in place of SPI however found porting the C code of the required CRC difficult.

A bit off topic but for music I found the 33FJ128GP802 device capable of true CD quality 44K 16bit stereo FAT table read.  The 33FJ128GP802 also includes four 16 bit audio DACs of which two were utilized for stereo.  When connected to my stereo indistinguishable quality at least to my ears.

On a old SD card read speed test utilizing a 18F4520 350K bytes per second was noted.


tumbleweed

Class 4 and Class 10 cards would be 4MB and 10MB speeds, which would require SPI rates of 32Mbps and 80Mbps.

Most PIC24/dsPIC33 SPI rates top out at about 15-25Mbps, but there are some that can do up to 40Mbps on certain pins (33CH/CK).

That's just the hdw speed. Add to that the software overhead and you probably won't hit anywhere near those rates.

 

Wimax

Ok, but what is the speed (order of magnitude) that can be reasonably achieved when writing a file ?

tumbleweed

I haven't measured it (so take this for what it's worth)...
A few hundred KB, possibly even slower would be my guess.

What sort of times are you seeing?

Wimax

 :'(  I use a 24FJ64GA002 clocked at 32 MHz and the SPI BUS at 8 MHz. To transfer 256 KB in blocks of 1024 bytes each takes about 1 minute and 14 seconds with an average of 3.5 KB/s...
Unfortunately, I am forced to make a series of 'append' to a file, but it still seems like a low speed to me.

Wimax

#6
Just an update after few trials by using a buffer in the PIC24 RAM ranging in size from 1024 KB to 4096 KB, thus decreasing the number of 'Append' and transferring the entire buffer "at once", I obtained these numbers to write 768 KB:

4 GB class 4 SDHC (FAT32) : approx. 60 seconds

32 GB class 10 SDHC  (FAT32) : about 120 seconds ! Why ?

Does anyone have better statistics than me ? Or are these numbers to be considered 'normal'?

I think that the Class of the card is not so important using the SD with SPI bus, but the write access time is fundamental as, in my case, I perform multiple write access every time. I will try with another card that seems to have a very low write access time... .

Wimax

Hello Friends !  ;D

After several trials I can summarise something.

Device: 32 GB MicroSD SanDisk Extreme Pro.

Previous calculations were not accurate as the save format actually generated more bytes on the SD than the starting bytes. I optimised the saving format by directly choosing Int8 without modifiers and CRs.
I decreased the number of 'append' as much as possible by buffering the data in the micro's RAM in a reasonable way (a 4 KB buffer).
Tests indicate that transferring 1MB to SD takes about 20 seconds (about 51 KB/s) which is a very reasonable time compared to the numbers I have obtained in past tests.
Perhaps something could be gained by having a micro with more RAM, but the results seem good.