I have a ‘Daisy’ mp3 player (http://www.teuthis.com/html/daisy_mp3.html
) , and it works fine, as pre-programmed. I am trying to adapt the source code(written for CCS PCH C compiler), so that it compiles and works properly with C18 . I’m using the hardware SPI feature on the 18F45j10, to read the SD memory chip.
My SD memory is Fat32 formatted, and I am able to inspect the actual data with a USB media reader, and a physical sector read utility.
Any ‘read block’ commands I issue with my code, always return defective data, when the last (LSB) three address bits are either ‘100’, or ‘101'.
For example, my block of data at sector 141 actually is:
01 14 00 00 02 14 00 00 03 14 00 00 04 14 00 00
A series of SPI ReadSPI() calls will return:
01 14 00 0F 04
14 00 00 03 14 00 00 0F 04
No matter what 512 byte SD memory block I open, the 4 LSB bits of byte 0x?4 and 0x?C will be set to ‘F
’, and bytes 0x?5 and 0x?D will be 0x04
Now, I have about 400 lines of ‘bare bones’ code I can post, and I really would appreciate some help. I am a newbie to SD memory and PICs, but just can’t imagine how it is possible to be able actually access the memory, and get only PARTIALLY bad data!
I am using:
C18 C Compiler v3.11
Hardware SPI library (spi.h, from the C18 install)
I get the same result with SPI modes:
OpenSPI(SPI_FOSC_64, MODE_00, SMPEND); //or SMPMID
And OpenSPI(SPI_FOSC_64, MODE_11, SMPEND);