EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / SD care interface with LPC2148 on NSK development board

SD care interface with LPC2148 on NSK development board

|

Projects › Projects › SD care interface with LPC2148 on NSK development board

  • This topic has 1 reply, 2 voices, and was last updated 11 years, 4 months ago by AJISH ALFRED.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • November 24, 2014 at 12:04 pm #3325
    Suhail
    Participant
    SD 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 #12374
    AJISH ALFRED
    Participant

    Hi,

    Try with 2GB, 1GB SDcards. Don’t use microSD card with SD card adapter.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Some opamp advice please April 12, 2026
  • isolating S-params in of PCB board without connectors April 11, 2026
  • want help with microprocessor April 11, 2026
  • Voltage comparator circuit verification April 11, 2026
  • Integrating 0–5V ECU Signals into a Double-DIN Setup – Module vs Custom Head Unit? April 11, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise