I am trying to interface SD card with LPC1768 MCU using CMSIS file system middleware. I have configured the system in SPI mode using memory card drive(M0:).Initialization function returns the desired fsOK value.But the following function i.e. amount keeps on returning fsMediaError.What could be the issue ?
Here is the code:-
#include"lpc17xx.h" #include"rl_fs.h" fsStatus stat; int main(void) { LPC_GPIO2->FIODIR=0XFFFFFFFF; stat = finit ("M0:"); \ if (stat==fsOK) { stat = fmount ("M0:"); switch(stat){ case fsOK: LPC_GPIO2->FIOPIN= 0xfffffff1; break; case fsUninitializedDrive: LPC_GPIO2->FIOPIN= 0xfffffff2; break; case fsInvalidParameter: LPC_GPIO2->FIOPIN= 0xfffffff3; break; case fsInvalidDrive: LPC_GPIO2->FIOPIN= 0xfffffff4; break; case fsDriverError: LPC_GPIO2->FIOPIN= 0xfffffff5; break; case fsMediaError: LPC_GPIO2->FIOPIN= 0xfffffff6; break; case fsNoMedia: LPC_GPIO2->FIOPIN= 0xfffffff7; break; case fsNoFileSystem: LPC_GPIO2->FIOPIN= 0xfffffff8; break; } }
>>What could be the issue ?
Let's think.. The pins, connectivity and functionality of the SPI/SDIO layer aren't working properly?
Test the SPI/SDIO layer can successfully read and write blocks to the card. Look at the code, and signals on the pins, etc.