electronics forum

Rules | Recent posts | topic RSS | Search | Register  | Log in

SPI_EEPROM INTERFACE WITH LPC2114


Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> SPI_EEPROM INTERFACE WITH LPC2114
Author Message
pavan_85



Joined: 03 Jul 2008
Posts: 27
Helped: 1
Location: hyderabad


Post29 Oct 2009 17:35   

SPI_EEPROM INTERFACE WITH LPC2114


hi all,
does any one of u have schematic for interface of spi eeprom (like 25c160 or any other IC) with lpc 2114......

if s pleaz post it......

thanks in advance...
pavan
Back to top
Google
AdSense
Google Adsense




Post29 Oct 2009 17:35   

Ads




Back to top
bobcat1



Joined: 10 Jul 2002
Posts: 1118
Helped: 48


Post31 Oct 2009 13:22   

Re: SPI_EEPROM INTERFACE WITH LPC2114


Hi

To interface SPI is a bit easy all you need is to connect 4 wire

CLK (LPC21xx) -> CLK(25xx)
CS (LPC21xx)(can be any I/O ->CS(25xx)
MOSI (LPC21xx) -> MOSI(25xx)
MISO (LPC21xx) <- MISO(25xx)

You also need to connect vcc & Gnd to the 25xx chip and add some 100nF cap near the 25xx vcc pin

For software you will need to use the SPI protocol Driver (can be found in NXP site or search SPI & LPC in google) And a protocol software layer for the 25xxx (search 25xx and code in google )

All the best

Bobi

The microcontroller specialist
Back to top
pavan_85



Joined: 03 Jul 2008
Posts: 27
Helped: 1
Location: hyderabad


Post05 Nov 2009 17:03   

Re: SPI_EEPROM INTERFACE WITH LPC2114


hi all,
I was trying to simulate spi interface with protues;
memory - AT25F512A
uc - LPC 2141

My problem is that S0SPDR register is not getting updated.......
here is my code..please go through it and comment where i went wrong.....

waiting for your replies......
pavan.

Code:


#include <lpc21xx.h>

void pll_init(void);
extern unsigned char rd[5];
int main()
{
   
   //INITIALIZE THE PLL AND SET CCLK = PCLK = 12Mhz
   pll_init();
   
   //SPI ROUTINES
   spi_init();
   spi_write("lucky");
}

void pll_init(void)
{
   PLLCFG  = 0X00000060;
   PLLCON  = 0X00000001;
   PLLFEED = 0X000000AA;
   PLLFEED = 0X00000055;
   
   while(!(PLLSTAT&0X00000400));
   
   PLLCON  = 0X00000003;

   PLLFEED = 0X000000AA;
   PLLFEED = 0X00000055;   
   
   VPBDIV  = 0X09;
}
------------------------------------------------------------------
                                   SPI CODE
------------------------------------------------------------------
#include <lpc21xx.h>

#include "spi.h"

#define   READ   0x03         //   WRITE LATCH ENABLE
#define   WRITE   0x02         //   WRITE DATA (PROGRAM)
#define   WRDI   0x04         //   RESET WRITE ENABLE
#define   WREN   0x06         //   READ DATA FROM MEMORY
#define   RDSR   0x05         //   READ STATUS REGISTER
#define     WRSR       0x01         //   WRITE STATUS REGISTER
#define     SPIF           1 << 7


unsigned char rd[5];

void spi_init(void)
{
   PINSEL0 = 0x00005500;   //   SELECTING SPI MODE
   S0SPCCR   = 0x78;         //   100KHZ
    S0SPCR  = 0x20;         //   MASTER MODE WITH 8-BITS PER TRANSFER
   //IODIR0  = 0x00000080;   //   DECLARING SSEL0 AS AN OUTPUT
}

 
unsigned char spi_tx_rx(unsigned char val)
{

   S0SPDR = val;
   while((S0SPSR & SPIF)==0);
   return S0SPDR;
   
}
 
void spi_write(unsigned char *val)
{
   spi_tx_rx(WREN);
      spi_tx_rx(WRITE);
   spi_tx_rx(0X00);   //ADDRESS: HIGHER BYTE
   spi_tx_rx(0X00);   //ADDRESS: LOWER BYTE
   spi_tx_rx(0X00);
   while(*val)
   {
      spi_tx_rx(*val++);
   }

   wait();
}

void spi_read()
{
   int i;

   spi_tx_rx(READ);
   spi_tx_rx(0X00);   //ADDRESS: HIGHER BYTE
   spi_tx_rx(0X00);   //ADDRESS: LOWER BYTE
   for(i=0;i<5;i++)
   {
      rd[i] = spi_tx_rx(0x00);
      wait();
   }

   
}
/*
void write(unsigned char *dataa)
{
   while(*dataa)
      spi_write(*dataa++);
}

void read(void)
{
   int i;
   spi_read();
   for(i=0;i<5;i++)
   {
      rd[i] = spi_read();
      wait();
   }
}
  */
void wait()
{
   int j;
   for(j=0;j<50000;j++);
}

Back to top
Arabic versionBulgarian versionCatalan versionCzech versionDanish versionGerman versionGreek versionEnglish versionSpanish versionFinnish versionFrench versionHindi versionCroatian versionIndonesian versionItalian versionHebrew versionJapanese versionKorean versionLithuanian versionLatvian versionDutch versionNorwegian versionPolish versionPortuguese versionRomanian versionRussian versionSlovak versionSlovenian versionSerbian versionSwedish versionTagalog versionUkrainian versionVietnamese versionChinese version
Post new topic  Reply to topic    EDAboard.com Forum Index -> Microcontrollers -> SPI_EEPROM INTERFACE WITH LPC2114
Page 1 of 1 All times are GMT + 1 Hour
Similar topics:
LPC2114 problem with kit handelling (1)
LPC2114 problem with kit handelling (2)
LPC2114 problem- how to deal with undesired reset (1)
LPC2114 Linker Script (.LD file) (2)
What is the price of Philips LPC2114? (4)
need help with program to interface DS1307 with 16F877 (14)
How can i interface nokia 3200 with serial cable with AT Com (3)
lf356 interface with 89c51 along with adc (4)
MAX485 with SPI protocol to interface with microcontoller (1)
Simplorer interface with C/C++ (1)


Abuse || Administrator || Moderators || Support us || sitemap
topic RSS