Dual Port SRAM corrupted unless read after write
I have a custom board with an stm32f733zet6 and an stlink-v3mods as a programmer/debugger.
Attached is a CY7C006A-20 dual port static ram which asynchronous and I'm using it without wait. I'm running 216MHz off HSI + PLLCLK
I've set timing values of 1, 1, 3 for AddressSetup, AddressHold and DataSetup respectively and it seems to work as I'm able to write some test data and read it back and it compares the same.
I'm using this setup as a Gameboy cartridge emulator of sorts so I'm writing a specific sequence of bytes which are checked during device boot. I hold the reset line low, write the data, release the reset line, and it begins to boot. This is where things get confusing: if I just write the data, the logo is all garbled on screen. But, if I read the data back before I release the reset line, it all works. The relevant section where I write:
// HAL_Init() etc
// uint8_t data[] { ... } above
for (int i = 0; i < sizeof(data); i++) {
(*(volatile uint8_t*)(NOR_MEMORY_ADRESS1 + i)) = data[i];
}
HAL_Delay(500);
// If I omit this loop the data is seemingly corrupt
int ii = 0;
for (int i = 0; i < sizeof(data); i++) {
ii = *(volatile uint8_t*)(NOR_MEMORY_ADRESS1 + i);
}
HAL_GPIO_WritePin(CART_NRST_GPIO_Port, CART_NRST_Pin, GPIO_PIN_SET);
while (true) { HAL_Delay(500); }I'm not sure what could be causing this.
