November 24, 2014 at 12:04 pm #3325SuhailParticipantSD care interface with LPC2148 on Development Board NSK
I am trying to integrate SDcard on to my project. My basic Aim is to transfer files to SDcard. The files are nearly 5MB to 10 MB in size. I used NSK electronics LPC 2148 development board. There are some sample SD card programs given.
I compiled the code. The SD card initialization was unsuccessful. The sd_initinialize() function has two conditions :sd_init() and sd_state() is returning is returning a negative value, which means that the SD card is not initialized.
The LCD shows “SD CARD – not OK”
I crossed checked the PIN configuration and spisend() function check, but i still couldn’t figure what is wrong ?
Source code for main.c
//void delay(unsigned long int count1);
void wait (void);
int main (void)
unsigned char i;
unsigned char SDCheckFlag;
lcd_print("SD card - OK");
SDCheckFlag = 1;
//else if(init_sdcard() == -1)
// lcd_print("SD Card-error = -1");
//else if(init_sdcard() == -2)
// lcd_print("SD Card-error = -2");
lcd_print("SD card - not OK");
SDCheckFlag = 0;
Source Code for lpc2000_sd.c
#include <LPC214x.H> /* LPC214x definitions */
#define SD_CARD BIT20
#define SD_SELECTION_DIR_SET (IO0DIR |= SD_CARD)
#define SD_SELECTION_SET (IO0SET = SD_CARD)
#define SD_SELECTION_CLR (IO0CLR = SD_CARD)
esint8 if_initInterface(eint8* opts)
DBG((TXT("Card failed to init, breaking up...n")));
DBG((TXT("Card didn't return the ready state, breaking up...n")));
// file->sectorCount=4; /* FIXME ASAP!! */
// DBG((TXT("Init done...n")));
euint8 if_spiSend(euint8 outgoing)
while ( !(SSPSR & SSPSR_TNF) );
SSPDR = outgoing;
while (!(SSPSR & SSPSR_RNE));
incoming = SSPDR;
esint8 if_readBuf(hwInterface* file,euint32 address,euint8* buf)
esint8 if_writeBuf(hwInterface* file,euint32 address,euint8* buf)
November 26, 2014 at 9:17 am #12374AJISH ALFREDParticipant
Try with 2GB, 1GB SDcards. Don’t use microSD card with SD card adapter.
- You must be logged in to reply to this topic.