- This topic has 1 reply, 2 voices, and was last updated 9 years, 10 months ago by AJISH ALFRED.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
November 24, 2014 at 12:04 pm #3325SuhailParticipantSD care interface with LPC2148 on Development Board NSK
Hi,
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
#include <LPC214X.H>
#include "lcd.h"
#include "type.h"
#include "types.h"
#include "lpc2000_spi.h"
//#include "ssp.h"
//void delay(unsigned long int count1);
void wait (void);
U8 init_sdcard(void);
int main (void)
{
unsigned char i;
unsigned status;
unsigned char SDCheckFlag;
lcd_init(); {
lcd_write_control(0x01);
goto_cursor(0x00);
if(init_sdcard())
{
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");
//}
else
{
lcd_print("SD card - not OK");
SDCheckFlag = 0;
}
delay(100000);
}
}
Source Code for lpc2000_sd.c
#include <LPC214x.H> /* LPC214x definitions */
#include "lpc2000_spi.h"
#include "sd.h"
#include "type.h"
#include "ssp.h"
#include "utils.h"
#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)
{
if_spiInit();
if(sd_Init()<0)
{
DBG((TXT("Card failed to init, breaking up...n")));
return(-1);
}
if(sd_State()<0)
{
DBG((TXT("Card didn't return the ready state, breaking up...n")));
return(-2);
}
// file->sectorCount=4; /* FIXME ASAP!! */
// DBG((TXT("Init done...n")));
else
return(0);
}
euint8 if_spiSend(euint8 outgoing)
{
euint8 incoming=0;
while ( !(SSPSR & SSPSR_TNF) );
SSPDR = outgoing;
while (!(SSPSR & SSPSR_RNE));
incoming = SSPDR;
return(incoming);
}
void if_spiInit()
{
spi1_init();
SD_SELECTION_DIR_SET;
SD_SELECTION_CLR;
}
#if 0
esint8 if_readBuf(hwInterface* file,euint32 address,euint8* buf)
{
return(sd_readSector(file,address,buf,512));
}
esint8 if_writeBuf(hwInterface* file,euint32 address,euint8* buf)
{
return(sd_writeSector(file,address, buf));
}
#endif
November 26, 2014 at 9:17 am #12374AJISH ALFREDParticipantHi,
Try with 2GB, 1GB SDcards. Don’t use microSD card with SD card adapter.
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.