SD Card Speed Issues
handermanntr
Posts: 18
in Accessories
Hello All,
I have an SD Card FAT class I built, and all works fine, but I have noticed that not all cards that have the TRAN_SPEED in the cards CSD set to 32(signaling a max clock of 25MHz) can handle data read at 10MHz and write at 20MHz from the propeller. For now, I have my class setup to auto detect the max speed. Does anyone know why certain cards that say they will support up to 25MHz with the TRAN_SPEED setting do not actually support it? I would like to get rid of the auto speed detection if possible, but I want to know why it is a problem in the first place. BTW, when I use to high of a speed, the R1 response is correct from the card, but the data I receive is all jumbled with no discernible pattern. Also, some cards do work with 10Mhz read and 20MHz Write fine(1GB sandisk microSD), i mostly have the problem with read and write not working at max speed on older 64MB or 256MB cards. Thanks!
I have an SD Card FAT class I built, and all works fine, but I have noticed that not all cards that have the TRAN_SPEED in the cards CSD set to 32(signaling a max clock of 25MHz) can handle data read at 10MHz and write at 20MHz from the propeller. For now, I have my class setup to auto detect the max speed. Does anyone know why certain cards that say they will support up to 25MHz with the TRAN_SPEED setting do not actually support it? I would like to get rid of the auto speed detection if possible, but I want to know why it is a problem in the first place. BTW, when I use to high of a speed, the R1 response is correct from the card, but the data I receive is all jumbled with no discernible pattern. Also, some cards do work with 10Mhz read and 20MHz Write fine(1GB sandisk microSD), i mostly have the problem with read and write not working at max speed on older 64MB or 256MB cards. Thanks!
Comments
For write, the fastest is 20MHz using the counters in NCO single-ended mode
Here is the counter init
Here is the write procedure, note that 'loop' is the main wait loop for the spi cog
Fastest for read is 10MHz since we can't link the counters to get input like we can link them for output
EDIT: I may just hookup the 100MHz scope and check those setup and hold times to be sure.
What I see in your code as a possible problem is that you don't set the phase of the clock generated by the Counter A. You just enable and disable the counter with movi frqa.... This does not affect the current PHSA value so the SPI-clock has a random phaseoffset to the read time point.
All the counter SPI methodes that I know sets first the PHSA then enables the counter with setting the mode in CTRA. FRQA is only set once at begin. It needs some try and error to find the right PHSA value, I've seen $E000_0000 and $6000_0000 in my objects collection.
You should look at the low level drivers for FSRW (in the OBEX) they do all the counter tricks and also a read-ahead and write-behind of blocks with a buffer in cogram.
There is the sdspi_safe driver with 10 MHz read, but also a faster one with a very nifty code from Kuroneko that can read with 20 MBit/s. (This works not with all cog/pin combinations, it really depends on the location of the cog on the die relative to the pin position).
Andy