Kingston 4GB SDHC class 4 cards - multi-block write problems.
Hardware:
PIC32MX795F512L @ 80MHz Fcy + PBCLK (yes, pbdiv = 0)
SPI2A @ 10MHz for now, card inits, writes & reads at up to 40MHz though
Kingston 4GB SDHC card, class 4
Software:
Language tool versions: pic32-as.exe v1.12, pic32-gcc.exe v1.12, pic32-ld.exe v1.12, pic32-ar.exe v1.12
MPLAB v8.66
Having problems, probably card related. Firstly, the card takes ~140mS for the first multi block write to go through. It succeeds ok, and this is only after a power up + reset on the card. Can be kludged by doing a non-critical write first of all I suppose.
My problem is that multi block writes are failing after n number of writes - always the same number. I've been trying to write 50 or 100 sectors, but, they fail like so:
Blank sectors@:
...16,17,18,19...32,33,34.....48,49.....64.....96,97,98,99
This suggests a pattern, with the 4,3,2,1 blank sectors, I haven't repeated for 200 sectors yet. I tried writing from sector 10, but same results bar the then offset of 10 sectors. It's always in the pattern described above.
I'm waiting for busy signals to clear (waiting until not 0x00 is returned) and get an E5 response for all the blocks written.
With multi-block writes, specs say prefix each block with 0xFC, until the last block, which should be prefixed with 0xFB to end writing. If I do that, the last block fails.So, I write an extra block of 0xFF as a work around, CRC'd @ 0x7FA1 again as per specs. I've got CRC turned on and working for CMDs and block / multi block writes.
I've also checked the status after the last block of a multi-block write, and got back 0x00. I'm inclined to say this means it's ok, but it could again be a busy signal maybe?
I'm on the point of ordering more memory cards to check against, but the 2GB card I chucked in to try failed as the replies are out of sync with the code I've written for the 4GB card.
Any debug suggestions / ideas would be great :)