Good morning,
I have doubt in spi.i have LPC3250 interfacing with SPI(AT25256AW).
void main() {
eeprom_write(0x0000,0x55); eeprom_read(0x0000);
}
void eeprom_write(unsigned short addr, unsigned char dat8) { unsigned char data [8];
/* send WREN command */ SPI1_CON|=0x00000004; //SPI1 is a Tx data [0] = 0x06; P3_OUTP_CLR=0x40000000; //cs=0 SPI_WR(data,1); SPI_Delay(10); P3_OUTP_SET=0x40000000; //cs=1 puts("\n\r NMS CARD2..............");
/* wait for EEPROM to become ready and write enabled - use RDSR */ /* loop until RDSR bit 1 becomes 1 and RDSR bit 0 becomes 0 */ while ((eeprom_rdsr() & 0x03) != 0x02); } unsigned char eeprom_rdsr(void) { unsigned char data[2],var,temp;
SPI1_CON|=0x00000004; //SPI1 is a Tx data[0] = 0x05; //prepare RDSR P3_OUTP_CLR=0x40000000; //cs=0 SPI_WR(data,1); SPI_Delay(10); SPI1_CON&=0xfffffffb; //SPI1 is a Rx SPI_Delay(10); data[0]=0xff; SPI_WR(data,1); //dummy write //temp=SPI1_DAT; SPI_Delay(10); P3_OUTP_SET=0x40000000; //cs=1 var=SPI_RD(); return var; }
I was writing the WREN command. I observe the output in osciiloscope the output is 10000110, but i did not get the output in hyper terminal properly i.e output(0000).
Thanks®ards Prabha