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.

plzz help in SPI interfacing AT25256w and P89LPC938....

Status
Not open for further replies.

sara_123

Newbie level 6
Joined
Apr 25, 2008
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,373
Hi,

I want to interface AT25256w eeprom with P89LPC938 uing SPI...from controllerLPC938 data is coming through MOSI..but while reading the eeprom the data is not coming correclty through MISO from the slave....can any body helpp......
 

Not getting the clear idea from this? There might be problem in drawing.
 

in eeprom first i am writing data using the commands and while reading the data from the location the data is not been correcltly read....have attached the code for reading and writing the data..
plzzz helpp.....

void EEPROM_WRITE_INT(void)
{
spi_onn();

cs_start();
spi_write(0x00);
cs_stop();
cs_start();
Delay(5);

spi_write(WREN);//write enable command


spi_write(WRSR);//write status register command

spi_write(0x02);
cs_stop();
spi_oFF();


}

BYTE spi_read(void)
{
BYTE Spdatatem;
SPDAT = 0x00;//0;
Spdatatem = SPDAT;
while(!(SPSTAT)); //spif ==0 shifting over
{
SPSTAT =0x00;
Port1 = Port1 | EE_CS_H; //cs=1
}
return SPDAT ;

}

void spi_write(BYTE spidatawr)
{

SPSTAT |= 0x80;
SPDAT = spidatawr;

while((SPSTAT & 0x80) == 0); //spif ==0 shifting over

SPSTAT |= 0x80;

}


void EEPROM_WRITE(BYTE add_h,BYTE add_l,BYTE dataee)
{

EEPROM_WRITE_INT();
spi_onn();
cs_start();

spi_write(WRITE);
Delay(5);
spi_write(add_h);

spi_write(add_l);

spi_write(dataee);

cs_stop();
spi_oFF();

}



BYTE EEPROM_READ(BYTE add_h,BYTE add_l)
{
BYTE dataslave,Tempdata;
BYTE TempCtr,Temp;

spi_onn();
cs_start();
if(readenable( )== 1)
{

spi_write(READ);//read
spi_write(add_h);
spi_write(add_l);

Temp = spi_read();
DisplayValue(3,Temp,2);

Port1 = Port1 | EE_CS_H;
}
else
readenable();
return Temp;

}
 

Sara,
I have not used AT25256w & from ur code it is very difficult to tell anything because the problem is related with spi(MOSI,MISO,CLK).
I will just suggest u that :
1) transmit data on leading edge of clock &
2) receive data on trailing edge of clock(failling edge).
Also chk connections & debug on oscilloscope.

Added after 8 minutes:

Also go through page 8 of datasheet.(Read sequence)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top