Electronic – Multiple SRAM on one MCU

sramstm32

I want (have) to use external SRAM on my STM32 and want to have in total 16Mbit.
Because big SRAM is quiet expensive, I want to use 2 smaller ones.
The question is, how do I achieve this (google is no big help in this case :/ )

My idea was that I use the 19 Adress lines for the first SRAM Chip and then for the second SRAM chip I use the lower 18 + 20th Adress line, so this memory scheme applies:

SRAM1: 0x00000 - 0x7FFFF
SRAM2: 0x80000 - 0xFFFFF

plus Offset of course 😉

The last thing is the Chip select line, but I can achieve this with a simple NOT-Gate

CS1 = ¬A[19] (indexed zero)
CS2 =  A[19]

Does this work? I'm concerned about rise and falltimes and delay from the gates. Does anyone have ever thought about this or even have experience?

Best Answer

This would work fine. The gate propagation delay for the cs line will be in the datasheet for the part you use but they are normally small enough to not be an issue. Worst case you can add an extra wait state to the memory controller in the CPU.

Alternatively you could put the two memory chips in parallel rather than series. Instead of using 2x 512K x 16 SRAM you could use 2x 1M x 8 SRAM. The price is the same, which makes sense since it's the same amount of memory. You then connect all of the address lines to each chip. D0-7 go to the first chip, D8-15 go to the second. You still have to route all the address lines to both chips but each data line only goes to a single location so in theory layout is a little bit easier.

The down side is that if you later decide you only need half the memory you can't simply remove one of the chips to halve the RAM fitted.