Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

SPI_EEPROM INTERFACE WITH LPC2114

Status
Not open for further replies.

pavan_85

Member level 1
Joined
Jul 3, 2008
Messages
33
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Location
hyderabad
Activity points
1,497
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
 

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
 

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++);
}
 

Hi,

Pavan, even me also same problem.i didnt get the result on proteus simulation.if u get the result plz give that file.its great help to me.this is my mail id.lavanyapydi.r@gmail.com.plz reply assp.i waiting for ur reply.thank you.
 

Here something for you. In schematic folder you will find a proteus project. This code was written in Keil.
 

Attachments

  • 24C+25CEEPROM+LPC2101.rar
    185.7 KB · Views: 51
  • Like
Reactions: lavi

    lavi

    Points: 2
    Helpful Answer Positive Rating
Hi,

Thanks for sending the code.and i want another help from u.can u plz send the code for i2c(24c04)with lpc2148.I tried this one but i didn't get the output.I am attaching my
file with Proteus simulation.Please find the attached file and give me reply asap.I am waiting for your reply.
 

Attachments

  • i2c.rar
    79.3 KB · Views: 38

Sorry, for I2c I had many problems with LPC and didn't solved them yet. I tried to use the same polling method and used only simulation to analyze the results. I don't have any real debug tools for Philips's ARMs. So, I'm not fully trust proteus. Possible later I'll try again. Try to find examples with google. As I remember, all steps controlled through status register and I had many problems with them in simulation.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top