conkhicon
Advanced Member level 4
I can't read out from MMC card when use PIC18F8720
- I do init it OK
- I write into OK (belong to status it's return)
- I read at address 512
MMC return to me a 0 (R1 OK)
but I loop send 0xff to wating a begin of datatoken 0xfebut don't match.
Can you help me?
#define BLOCK_LEN 16
my call:
readBlockMMC(0,512,bufMMC);
my sourcecode:
unsigned char readBlockMMC(unsigned long int DWAddr,unsigned char *pdes)
{
unsigned char localRD;
unsigned char dataToken;
Nop();
lowerSS(); // Card Active
writeCMD(17,DWAddr,0xff);// READ COMMAND (None CRC)
if(MCCResponse()!=0) {
MMC_Err = 0x30;
return(1);
}
Nop();
while(1) {// Waiting DATA TOKEN
WriteSPI(0xff);
dataToken = ReadSPI();
if(dataToken==0xfe) break;// Success
if((dataToken&0xe0)==0) {// Error Token
Nop();
MMC_Err = 0x31;
return(1);
}
}
Nop();
for(localRD=0;localRD<BLOCK_LEN;localRD++) {
WriteSPI(0xff);
*pdes = ReadSPI();
pdes++;
}
WriteSPI(0xff); // CRC
WriteSPI(0xff);
raiseSS(); // Card InActive
Nop();
return(0);
}
- I do init it OK
- I write into OK (belong to status it's return)
- I read at address 512
MMC return to me a 0 (R1 OK)
but I loop send 0xff to wating a begin of datatoken 0xfebut don't match.
Can you help me?
#define BLOCK_LEN 16
my call:
readBlockMMC(0,512,bufMMC);
my sourcecode:
unsigned char readBlockMMC(unsigned long int DWAddr,unsigned char *pdes)
{
unsigned char localRD;
unsigned char dataToken;
Nop();
lowerSS(); // Card Active
writeCMD(17,DWAddr,0xff);// READ COMMAND (None CRC)
if(MCCResponse()!=0) {
MMC_Err = 0x30;
return(1);
}
Nop();
while(1) {// Waiting DATA TOKEN
WriteSPI(0xff);
dataToken = ReadSPI();
if(dataToken==0xfe) break;// Success
if((dataToken&0xe0)==0) {// Error Token
Nop();
MMC_Err = 0x31;
return(1);
}
}
Nop();
for(localRD=0;localRD<BLOCK_LEN;localRD++) {
WriteSPI(0xff);
*pdes = ReadSPI();
pdes++;
}
WriteSPI(0xff); // CRC
WriteSPI(0xff);
raiseSS(); // Card InActive
Nop();
return(0);
}