krish121
Newbie level 4
- Joined
- Jan 29, 2013
- Messages
- 5
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,315
hi! i am interafcing eeprom with spi pic 18f . i am using following setting but my code doesn’t work.. i m using 25AA040 eeprom ..
SSPSTAT =0×40; // SPI MASTER MODE, spi clock select bit CKE=1
SSPCON1=0X30; // ckp=1
then spi write command
unsigned char spi_write(char c)
{
SSPBUF=c;
while(!SSPSTATbits.BF);
return SSPBUF;
}
i follow sequence in datasheet of 25aa040 to write data but when i read data it always zero result please help me.
to write data
CS = 0;
command for write enable
cs=1;
cs=0;
command for write instruction
command for lower address
send data
command for write disable
cs=1;
to read data
cs= 0;
command for read instruction
command for lower addreaa
data=SSPBUF; // read data
cs=1;
read data is at same location where i write data…. please help me..
SSPSTAT =0×40; // SPI MASTER MODE, spi clock select bit CKE=1
SSPCON1=0X30; // ckp=1
then spi write command
unsigned char spi_write(char c)
{
SSPBUF=c;
while(!SSPSTATbits.BF);
return SSPBUF;
}
i follow sequence in datasheet of 25aa040 to write data but when i read data it always zero result please help me.
to write data
CS = 0;
command for write enable
cs=1;
cs=0;
command for write instruction
command for lower address
send data
command for write disable
cs=1;
to read data
cs= 0;
command for read instruction
command for lower addreaa
data=SSPBUF; // read data
cs=1;
read data is at same location where i write data…. please help me..