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?

  • \$\begingroup\$ Are you waiting until the device is ready each time? \$\endgroup\$ May 1, 2016 at 4:20
  • \$\begingroup\$ @IgnacioVazquez-Abrams Yes, I'm polling the status register to see if the ready bit is 0, then I begin my write sequence. \$\endgroup\$
    – GisMofx
    May 1, 2016 at 4:23
  • 3
    \$\begingroup\$ Are you taking CS high after the write? Can you post code snippet and schematic? \$\endgroup\$ May 1, 2016 at 5:12
  • \$\begingroup\$ @RogerRowland Yes and yes. \$\endgroup\$
    – GisMofx
    May 1, 2016 at 11:20
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – kkrambo
    May 1, 2016 at 15:11

1 Answer 1


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)
            ushort spanAddress = AddressSpansPage(startAddress, byteBuffer.Length);
            if (spanAddress != 0)
                //perform write on first half
                byte[] splitBuffer= new byte[spanAddress-startAddress];
                Array.Copy(byteBuffer, 0, splitBuffer, 0, spanAddress - startAddress);
                WriteBytes(startAddress, splitBuffer);

                //perform write on second half
                ushort endAddress = (ushort)((startAddress + byteBuffer.Length) - 1);
                splitBuffer = new byte[(endAddress - spanAddress) + 1];
                Array.Copy(byteBuffer, spanAddress-startAddress, splitBuffer, 0, splitBuffer.Length);
                WriteBytes(spanAddress, splitBuffer);

            else WriteBytes(startAddress, byteBuffer);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.