Hi,
I have interfaced AT25F1024 SPI-EEPROM with LPC2129. The code is to write a single byte of character in to the AT25F1024 & again read the same byte & display on the lcd. I know how to display on the lcd. but i don't know how to write & read a byte from AT251014. I also followed the instructions present in the datasheet of AT25F1024. but the code is not working. can anybody tell how to write & read a byte from AT25F1024 by using LPC21XX.
#include<LPC21XX.h>#include"SPILCD.h"//LCD PROGRAMM #define slave2 1<<7 //CHIP SELECT PINint main(void){unsignedchar dat,ch='A',gar;
PLLCFG=(1<<2)|(1<<5);//SETTING THE CORE CLOCK AS 60MHZ & PCLK AS 15MHZ
PLLCON=(1<<0)|(1<<1);// ENABLE THE PLL
PLLFEED=0XAA;
PLLFEED=0X55;
IODIR0=slave2;// MAKING CHIP SELECT PIN IN LPC21XX AS OUTPUT PIN
IOSET0=slave2;// SLAVE IS DEACTIVATED
PINSEL0|=(1<<8)|(1<<10)|(1<<12);// MAKING THE PINS AS SCLK,MISO,MOSI
S0SPCCR=5;// SPI BIT RATE IS 3MHZ
S0SPCR|=(0<<3)|(0<<4)|(1<<5)|(0<<6);//CLK POLARITY & CLK PHASE AS 0, LPC21XX AS MASTER & MSB IS TRANSMITTED FIRST
gar=S0SPSR;// CLEARING THE STATUS REGISTER
IOCLR0=slave2;// SLAVE IS ACTIVATED
S0SPDR=0X06;//WRITE MODE INSTRUCTION IN AT25F1024 EEPROMwhile((S0SPSR&(1<<7))==0);// MONITORING THE FLAG UNTIL THE LAST BIT IS TRANSMITED
gar=S0SPSR;// CLEARING THE STATUS REGISTER
S0SPDR=0X04;//DATA // DATA TO BE PUT IN THE AT251024 EEPROMwhile((S0SPSR&(1<<7))==0);// MONITORING THE FLAG UNTIL THE LAST BIT IS TRANSMITED
gar=S0SPSR;// CLEARING THE STATUS REGISTER
IOSET0=slave2;//SLAVE IS DEACTIVATED
delay(100);// SOME DELAY
IOCLR0=slave2;//SLAVE IS ACTIVATED
S0SPDR=0X03;//READ MODE INSTRUCTION IN AT25F1024 EEPROMwhile((S0SPSR&(1<<7))==0);// MONITORING THE FLAG UNTIL THE LAST BIT IS TRANSMITED
gar=S0SPSR;// CLEARING THE STATUS REGISTER
S0SPDR=0X00;//DATA CONTAINED IN ADDRESS OF AT25F1024 EEPROM
S0SPDR=0X00;while((S0SPSR&(1<<7))==0);
gar=S0SPSR;
dat=S0SPDR;//THE DATA STORED IN EEPROM IS COPIED IN TO A VARIABLE
IOSET0=slave2;// SLAVE IS DEACTIVATED
INIT_LCD();if(dat==0x04)
DAT_LCD('A');else
DAT_LCD('B');while(1);}