My design executes code directly out of a flash chip on CS0. Now I need to be able to erase and program a portion of this chip for logging purposes.
I wrote a simple routine to query the flash chip's device info, but everything I try just gets me the contents of flash (not the actual device info).
Is there a trick that I'm missing? Our flash chip is a Spansion S29GL064S (8Mbyte, 16-bit). Here's the code that I'm running:
void RAMFUNC ram_flash_status(uint32_t flashAddr) {
volatile uint16_t *flash555 = (uint16_t *)(0x555 * 2);
volatile uint16_t *flash2AA = (uint16_t *)(0x2AA * 2);
volatile uint16_t *flashPtr = (uint16_t *)flashAddr;
int idx;
// Read the device information
*flash555 = 0x00AA; // Cycle #1
*flash2AA = 0x0055; // Cycle #2
*flash555 = 0x0090; // Cycle #3
for (idx = 0; idx < DEVINFO_SIZE; idx++) {
flash_devinfo[idx] = flashPtr[idx];
}
// Issue Reset command
*flash555 = 0x00F0; // Cycle #1
}