Discussion group dedicated to the Philips LPC2000 family of ARM MCUs
SPI_EEPROM INTERFACE WITH LPC2114 - pavannaidu_v - Nov 5 14:42:22 2009
Hi,
I want to interface AT25F512A with LPC 2141.
My problem is that DATA REGISTER S0SPDR is not taking any values...
I used Proteus to simulate the above......
here is my code.....plz go thru it and tell me where the fault is.....
CODE:
void spi_init(void)
{
PINSEL0 = 0x00005500; // SELECTING SPI MODE
S0SPCCR = 0x78; // 100KHZ
S0SPCR = 0x20; // MASTER MODE WITH 8-BITS PER TRANSFER
// 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 wait()
{
int j;
for(j=0;j<50000;j++);
}
------------------------------------

(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )
Re: SPI_EEPROM INTERFACE WITH LPC2114 - capiman26061973 - Nov 5 15:55:18 2009
Hello,
> plz go thru it and tell me where the fault is.....
...Own remarks removed...
Some question which could help to solve your problem yourself:
What have you already checked ?
You told us you have simulated it with proteus. What was the result ? Was it working there
?
Have you compared your code with the huge amount of SPI codes which was meanwhile posted
here in the group or uploaded to file section ?
Ever heard of jc wren ? Google for him ! It is worth ! Code for LPC2148 can be helpful
also in your situation.
Have you searched in this group what others have done wrong with SPI
and if you are doing the same errors ?
Have you googled for AT25F512A ?
Or for SPI and LPC as suggested by bobcat1 on
http://www.edaboard.com/ftopic369147.html ?
You have not told us if you still use your proteus or real hardware ?
Not really important if you use an emulator or real hardware: Have you checked, that
something is sent out via SPI ?
Have you checked that AT25F512A is answering ?
Have you checked the clocks of SPI, is it really the requested 100 kHz ? Is polarity of
SPI correct ? Bit-order does fit ?
Any other registers which are mentioned in the User Manual ?
Perhaps the following webpage is helpful:
http://www.embeddedrelated.com/groups/lpc2000/show/226.php
Especially notes about SSEL. Check for their correctness !
I hope, you (at least) post your running code here in the group afterwards
and tell us what was wrong ?
Regards,
Martin
------------------------------------

(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )
Re: SPI_EEPROM INTERFACE WITH LPC2114 - pavannaidu_v - Nov 5 23:12:09 2009
Hi martin,
I wanted to check my code first in the proteus simulator. then i wanted to implement the
same in the hardware.I compared the code with others available on the net. They are mostly
the same.....
But yes, i vl c the links u have send, and hopefully will post the working code in a short
time.......
Thanks martin........
pavan.
--- In l...@yahoogroups.com, "capiman26061973"
wrote:
>
> Hello,
>
> > plz go thru it and tell me where the fault is.....
>
> ...Own remarks removed...
>
> Some question which could help to solve your problem yourself:
> What have you already checked ?
> You told us you have simulated it with proteus. What was the result ? Was it working
there ?
> Have you compared your code with the huge amount of SPI codes which was meanwhile posted
here in the group or uploaded to file section ?
> Ever heard of jc wren ? Google for him ! It is worth ! Code for LPC2148 can be helpful
also in your situation.
> Have you searched in this group what others have done wrong with SPI
> and if you are doing the same errors ?
> Have you googled for AT25F512A ?
> Or for SPI and LPC as suggested by bobcat1 on
> http://www.edaboard.com/ftopic369147.html ?
> You have not told us if you still use your proteus or real hardware ?
> Not really important if you use an emulator or real hardware: Have you checked, that
something is sent out via SPI ?
> Have you checked that AT25F512A is answering ?
> Have you checked the clocks of SPI, is it really the requested 100 kHz ? Is polarity of
SPI correct ? Bit-order does fit ?
> Any other registers which are mentioned in the User Manual ?
> Perhaps the following webpage is helpful:
> http://www.embeddedrelated.com/groups/lpc2000/show/226.php
> Especially notes about SSEL. Check for their correctness !
>
> I hope, you (at least) post your running code here in the group afterwards
> and tell us what was wrong ?
>
> Regards,
>
> Martin
>
------------------------------------
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of lpc2000 -- send a blank email to lpc2000-subscribe@yahoogroups.com )