Atmel SPI Serial EEPROM Writing Error - Page Write?

I'm using this EEPROM: Atmel AT25640B SPI EEPROM DATASHEET

It seems pretty straight forward to operate and I've followed the datasheet closely when coding my driver. I seemed to have some success without too much trouble. Now, I'm having some issue with writing bytes and they're not sticking. For example, I write 10 bytes, but when I immediately read them back(to verify they've been written, I get all 10 bytes back at 0. Is there possibly something fundamental that I'm missing with how to operate this EEPROM?

As I understand Page Write, I can write up to 32 bytes sequentially and then it will roll over to the start address? Are the "pages" physically set 0-31, 32-63, etc or are they determined by where you start writing? ex: If I write 8 bytes at address 29, will it roll over to 0 or will it continue as expected and finish writing at 36? The datasheet is not clear.

The basic steps seem to be to send a WRITE ENABLE Command(1). Then separately, send a WRITE Command followed by address and the bytes to write.

I'm running the at 5v. I've tried to slow down the SPI clock to 1khz from 10mhz with no difference in behavior.

What else can I try?

• Are you waiting until the device is ready each time? – Ignacio Vazquez-Abrams May 1 '16 at 4:20
• @IgnacioVazquez-Abrams Yes, I'm polling the status register to see if the ready bit is 0, then I begin my write sequence. – GisMofx May 1 '16 at 4:23
• Are you taking CS high after the write? Can you post code snippet and schematic? – Roger Rowland May 1 '16 at 5:12
• @RogerRowland Yes and yes. – GisMofx May 1 '16 at 11:20
• The datasheet you linked says, "The AT25320B/640B is capable of a 32-byte page write operation. After each byte of data is received, the five low-order address bits are internally incremented by one; the high-order bits of the address will remain constant." That means the pages are physically set 0-31, 32-63, etc. – kkrambo May 1 '16 at 15:11

This device has Page Write functionality. Pages are 32 bytes in size and fixed in address starting from 0. As pointed out by @kkrambo

0-31 32-63 ... etc

If writing a sequence of bytes across a page boundary, we need to break up the bytes into two parts at the point where one page ends and another begins.

Here's some sample code if a sequence spans across two pages(multiple pages are not addressed here):

public void WriteBytesPageSpan(ushort startAddress, byte[] byteBuffer)
{
{
//perform write on first half

//perform write on second half
}