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
From all that unformatted gibberish, I can only guess that you ran off the end of main too early.
What does hyper terminal have to do with SPI??
Please follow the clearly stated instructions for posting source code:
www.danlhenry.com/.../keil_code.png
Sorry, but your code isn't possible to read, because of bad formatting.
But another thing. Why summary "ARM9"? Didn't you think "Problem with SPI on LPC3250" would be a way better summary for the thread? Or is your main focus actually ARM9, and you don't care about SPI or the processor actually being an LPC3250?
The care you show when posting - summary, tagging code as code, ... - clearly indicate the care you also show when crafting your source code.