I'm attempting to talk a AT45DB081D chip over SPI using the following code:
void efContinuousArrayRead(unsigned char *data, unsigned int page, unsigned int offset, unsigned int length)
{
unsigned int index;
FLASH_SEL_ON
SPIShift(0x03);
SPIShift((unsigned char)(page >> 7));
SPIShift((unsigned char)((page << 1) | (offset >> 8)));
SPIShift((unsigned char)(offset & 0xFF));
for(index = 0; index < length; index++)
{
data[index] = SPIShift(0x00);
}
FLASH_SEL_OFF
}
I have several other commands working including:
- Buffer 1/2 Read
- Buffer 1/2 Write With / Without Page Erase
- Main Memory to Buffer 1/2
Given that these other commands work, I am reasonably confident that FLASH_SEL_ON, SPIShift, etc are working as expected.
Note that I am able to read from Page 0, any offset. However, I am unable to read from any page other than 0. This leads me to believe that the problem revolves around my math for specifying the page is flawed.
In debugging, I have found that for page 1, offset 0, the 24 bit address is calculated as:
00000000 00000010 00000000
This looks correct according to the datasheet spec for the format of the address:
xxxPPPPP PPPPPPPB BBBBBBBB
where:
- x unused
- P page number
- B offset
When I specify pageNumber = 0, I get the correct values back that I placed in there. However, when I specify pageNumber = 1, I get all 255 values instead of the values I placed there previously.
How do I specify the address for pages other than 0?