Content originally posted in LPCWare by capiman on Fri Nov 15 22:39:59 MST 2013
Hello Rich,
sorry, i don't know AT25040, but some general points:
- When you write one byte on SPI, you get automatically one byte on SPI. This is written to FIFO and remains there when you don't read it.
You are writing 3 bytes (i assume you have configured 8 byte transfers), then reading 1 byte.
The byte you are reading is the answer on the first byte written. Is this what you want?
Or do you perhaps need a dummy read after each write action?
- Are you sure the write operation (where you set 0xAA to location 0) was successful? Perhaps there is a 0x00 at this place and read is working?
- Have you checked the SPI lines signals with some probe (logic analyzer, scope, TTL pen)?
- This is perhaps dangerous (in term of you change something and forget to change both places):
while ((LPC_SSP0->SR & 0x10) == 0x10);
Perhaps use the following instead (is perhaps even faster to execute)
while ((LPC_SSP0->SR & 0x10) != 0x00);
Best regards,
Martin