2026-03-11 3:19 AM - last edited on 2026-03-11 3:22 AM by mƎALLEm
I'm trying to set up FSMC in muxed mode to read_write external NOR flash devices. Muxed pins goes through 2 8-bit latches 74HC574D.
The problem is that currently i can barely read from external NOR and it's not accepting commands.
Firstly HAL_NOR_Init(&hnor1, &Timing, NULL) returns HALL_ERR since it fails to read CommandSet from NOR. It should read address 0x13 from CFI and get 0x02 or 0x01 as a result, but write commad makes no effect and as a result driver reads at 0x13 from memopry start.
After analyzing what's going on on the FSMC bus I still cand fing any clues. Here is an example how it performs ReadID sequence, using standard HAL_NOR_ReadID
Everything looks correct, 3 sequences 0x555 - >0xAA, 0x2AA -> 0x55 and 0x555 -> 0x90, but reading 0x00 and 0x01 right after returns data from NOR not the deviceID
I've also tried bitbang mode with same pins and code below successfully reads deviceID. So after all it's not a witing problem, but maby timings or some FSMC setting
HAL_StatusTypeDef NOR_ReadID_Manual(uint16_t* manufacturer, uint16_t* device) {
if (!manufacturer || !device) return HAL_ERROR;
NOR_Manual_Init();
write_nor(0x0000, 0xF0);
write_nor(0x555 * 2, 0x00AA);
write_nor(0x2AA * 2, 0x0055);
write_nor(0x555 * 2, 0x0090);
*manufacturer = read_nor(0x00 * 2);
*device = read_nor(0x01 * 2);
// Reset
write_nor(0x0000, 0xF0);
return HAL_OK;
}
I've tried different timings but it has no effect. Currently it runs on 21Mhz
With such init settings:
/** Perform the NOR1 memory initialization sequence
*/
hnor1.Instance = FSMC_NORSRAM_DEVICE;
hnor1.Extended = FSMC_NORSRAM_EXTENDED_DEVICE;
/* hnor1.Init */
hnor1.Init.NSBank = FSMC_NORSRAM_BANK1;
hnor1.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_ENABLE;
hnor1.Init.MemoryType = FSMC_MEMORY_TYPE_NOR;
hnor1.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_16;
hnor1.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE;
hnor1.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW;
hnor1.Init.WrapMode = FSMC_WRAP_MODE_DISABLE;
hnor1.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS;
hnor1.Init.WriteOperation = FSMC_WRITE_OPERATION_ENABLE;
hnor1.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE;
hnor1.Init.ExtendedMode = FSMC_EXTENDED_MODE_DISABLE;
hnor1.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE;
hnor1.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE;
hnor1.Init.PageSize = FSMC_PAGE_SIZE_NONE;
/* Timing */
Timing.AddressSetupTime = 4;
Timing.AddressHoldTime = 3;
Timing.DataSetupTime = 6;
Timing.BusTurnAroundDuration = 2;
Timing.CLKDivision = 16;
Timing.DataLatency = 17;
Timing.AccessMode = FSMC_ACCESS_MODE_A;
/* ExtTiming */
Solved! Go to Solution.
2026-03-11 5:36 AM
After Connecting RY|BY and enabling NWAIT i was able to read ID several times in a row:
Manufacturer: 0x00C2, Device1: 0x22BA, Device2: 0x0000, Device3: 0x0000
Before that i was able to read it couple times, but anly with physical contact with WE pin. Looks like NOR was not able to switch state fast enough, but it surprised me, since it was driver in debug mode only at 21mhz.
Thank you for your help!
2026-03-11 3:37 AM - edited 2026-03-11 3:52 AM
2026-03-11 3:57 AM
Hello
74HC573 was my first attempt, but I've fugured out that it holds address only while NADV is active
Following RM0090 it will latch address only during ADDSET and during ADDHOLD it will again became transparent
With 74HC574 at least read operations works.
I'm thinking about connecting RY\BY NOR output to FSMC_NWAIT
2026-03-11 4:07 AM
@Wassermann1 wrote:
74HC573 was my first attempt, but I've fugured out that it holds address only while NADV is active
You need a latch not a D-type flip flop and indeed you need to add an inverter to the latch LE input.
@Wassermann1 wrote:
Hello
With 74HC574 at least read operations works.
It reads but not all operations are performed correctly. right?
2026-03-11 5:36 AM
After Connecting RY|BY and enabling NWAIT i was able to read ID several times in a row:
Manufacturer: 0x00C2, Device1: 0x22BA, Device2: 0x0000, Device3: 0x0000
Before that i was able to read it couple times, but anly with physical contact with WE pin. Looks like NOR was not able to switch state fast enough, but it surprised me, since it was driver in debug mode only at 21mhz.
Thank you for your help!