# First time interfacing MCU with external SDRAM

#### TrackerFX

Joined May 18, 2020
13
(Links are component datasheets or application notes.) I have a project using the STM32H series MCU that requires external SDRAM for data storage. Due to the size, the PCB is going to cost near $1,000 to fab and so I'd like to make sure that the design is correct before sending it to the board house. I've found several application notes on the STM32H; however, none seem to answer all of my questions satisfactorily. The RAM chip I selected based on price and memory size, but I'm not sure about compatibility with the MCU as I'm new to the subject. Since the data being stored will be MIDI files, I chose the 1Gb (32M x 32) RAM chip W94AD2KBJX5I. As I understand it, MIDI files are made up of 32 bit chunks and so would require a 32 bit data bus? My concern with this chip is that it shows a CLK pin and a !CLK pin and the MCU app notes (pages 52-53) I've found only show a connection to CLK. Is the inverted pin left floating, grounded, or am I missing something here? I've also noted that there seem to be a pin or two on the STM32H that I don't see in the app notes but are listed in the MCU datasheet as part of the Flexible Memory Controller (FMC) such as the FMC_NWAIT pin. Does anyone with experience interfacing external SDRAM to the STM32H series MCUs mind giving me a rundown of this? #### dl324 Joined Mar 30, 2015 10,988 Due to the size, the PCB is going to cost near$1,000 to fab and so I'd like to make sure that the design is correct before sending it to the board house.
Then you should make a prototype and verify correct operation before having any boards made.

#### WBahn

Joined Mar 31, 2012
25,918
I very much second the suggestion. As with most engineering problems, it is highly desirable to break them down into small problems and solve those problems and then meld the small solutions into a bigger solution.

So if you are unfamiliar with working with the MCU/SDRAM combo, make a tiny little board that lets you play with that aspect of it and get a solution to that part of it that you are confident in.

#### Papabravo

Joined Feb 24, 2006
13,939
Just to be clear - what does the $1,000 cover? Is that per board fabrication? Does it include NRE? Does it include assembly and parts? Even if you get and build 3 pcs, what you will learn will be more than worth it when you get your first batch of production quantity. Thread Starter #### TrackerFX Joined May 18, 2020 13 @Papabravo$1,000 is the PCB only. I'm doing the assembly myself.

@dl324 @WBahn
Under normal circumstances I'd agree with you; however, I'm working with a 5 week deadline to have the project completed. I've done this kind of PCB layout and assembly, but never the actual schematic work. Just hoping someone would have some insights.

Also, this is a one time project, ie: not for production. The fewer rev.s the better.

#### MrChips

Joined Oct 2, 2009
21,350
I think that you should reconsider why you need to interface to SRAM. System memory is used by the MCU for storing and accessing variables that require high speed access. If you just need to access MIDI files then it would be a lot easier to store them on a micro-SD card. STM32 MCUs already have built-in interface to flash memory cards. You can have 64GB of memory for very little cost.

#### dl324

Joined Mar 30, 2015
10,988
Under normal circumstances I'd agree with you; however, I'm working with a 5 week deadline to have the project completed.
Don't make this another example of not having enough time to do it right, but having to make time to do it again.

#### TrackerFX

Joined May 18, 2020
13
@MrChips
I'll quote the request I received for this project:

"At the boot, maximum of 128 samples are loaded to SDRAM from NV mem (SDCard? Could also consider a supercap connected to the SDRAM?), starting at the highest address and growing inwards. Loaded samples will effectively be fixed in memory after boot. Active samples are populated and copied from the loaded segment as the user selects samples for a given track. The idea here is that at any point samples could be loaded or changed during the operation of the beat-machine. We need to have an explicit memory region for Active samples (as oppose to simple referencing the samples as they are in the loaded segment) as they will be modified through the operation of the machines. (e.g., applying envelopes, filters, effects, etc). On the STM32 RAM side, we’ll keep two pointer tables to the loaded and active samples so that we can reference them accordingly."

I specialize in robotics and automation. This project is slightly outside my comfort zone but I have done layouts and assembly on similar types of projects when I worked for another company, although there we had a guy who did all the schematic work.

#### MrChips

Joined Oct 2, 2009
21,350
How much memory do you really need?
High end STM32 already comes with 2MB flash and 692KB RAM.
RAM can be continuously loaded on the fly as needed with data from a 64GB micro-SD card. You don't need battery backed SDRAM.

#### BobTPH

Joined Jun 5, 2013
2,433
Why do I get the feeling that you are confusing SDRAM with an SD card, which is flash memory.

Bob

#### TrackerFX

Joined May 18, 2020
13
For this project to work there needs to be:
1. Storage for 128 unedited MIDI files. This ensures that any edited file can be restored to its unedited version. This memory needs to be non-volatile, ie: SD card. (MIDI has a max file size of 1GB so obviously the files will need to be smaller than max.)
2. Storage for 128 editable MIDI files. (Copies of #1 above.) This can be volatile memory.
3. Storage for 16 MIDI files that are currently loaded/playing. I assume this needs to be separate from #2 above to allow editing of the tracks while the tracks are playing. This can also be volatile memory.

The request I received is quoted in the above post. Also, this project is hardware only. I assume since the client is going to be programming this that they know what they want, but that is an assumption.

#### Papabravo

Joined Feb 24, 2006
13,939

Bob

#### TrackerFX

Joined May 18, 2020
13
**UPDATE**
I wish I had looked into the DDR aspects of this sooner because this all make much more sense now.

The MCU has a maximum output clock speed of 100 MHz, not near fast enough for DDR SDRAM so regardless of how the differential clock inputs are connected it wouldn't have worked anyway. The correct answer is to use non-DDR SDRAM. As far as clock frequency goes, page 2 of this App Note states, "Unlike DDR, there is no minimum clock frequency for SDRAM regardless of the speed grade." This allows use of any non-DDR SDRAM regardless of its rated maximum clock frequency. (Although the full potential of a chip with a higher max frequency could be realized.)

Hopefully this helps anyone in the future with similar questions.
Thanks again for everyone's help!

#### Papabravo

Joined Feb 24, 2006
13,939
**UPDATE**
I wish I had looked into the DDR aspects of this sooner because this all make much more sense now.

The MCU has a maximum output clock speed of 100 MHz, not near fast enough for DDR SDRAM so regardless of how the differential clock inputs are connected it wouldn't have worked anyway. The correct answer is to use non-DDR SDRAM. As far as clock frequency goes, page 2 of this App Note states, "Unlike DDR, there is no minimum clock frequency for SDRAM regardless of the speed grade." This allows use of any non-DDR SDRAM regardless of its rated maximum clock frequency. (Although the full potential of a chip with a higher max frequency could be realized.)

Hopefully this helps anyone in the future with similar questions.
Thanks again for everyone's help!
I for one am glad you avoided an expensive mistake. You're still not out of the woods, so good luck.

#### BobaMosfet

Joined Jul 1, 2009
1,121
(Links are component datasheets or application notes.) I have a project using the STM32H series MCU that requires external SDRAM for data storage. Due to the size, the PCB is going to cost near $1,000 to fab and so I'd like to make sure that the design is correct before sending it to the board house. I've found several application notes on the STM32H; however, none seem to answer all of my questions satisfactorily. The RAM chip I selected based on price and memory size, but I'm not sure about compatibility with the MCU as I'm new to the subject. Since the data being stored will be MIDI files, I chose the 1Gb (32M x 32) RAM chip W94AD2KBJX5I. As I understand it, MIDI files are made up of 32 bit chunks and so would require a 32 bit data bus? My concern with this chip is that it shows a CLK pin and a !CLK pin and the MCU app notes (pages 52-53) I've found only show a connection to CLK. Is the inverted pin left floating, grounded, or am I missing something here? I've also noted that there seem to be a pin or two on the STM32H that I don't see in the app notes but are listed in the MCU datasheet as part of the Flexible Memory Controller (FMC) such as the FMC_NWAIT pin. Does anyone with experience interfacing external SDRAM to the STM32H series MCUs mind giving me a rundown of this? Please do not have a PCB made until you breadboard something with the SDRAM. Your lack of understanding regarding the '32-bit' stuff with MIDI and the SDRAM seriously casts into doubt the success of your project at this stage- your PCB should not cost$1K. I design and have PCBs made all the time (including multi-layer/planes).

How you interface with memory and how you use it are two very different things.

In fact, truth to be told, unless you have working, previously tested designs to work from, you shouldn't even consider making a PCB until you know that each of your subsystems works and has been done on a breadboard and tested.

I have had many PCBs made. And even my largest 4 layer boards from a very expensive house did not cost anywhere near $1000. I reckon you need to look elsewhere. Lately, I have been using https://jlcpcb.com/ and am really pleased with them. When you have a PCB file done, send them the files and get a quote. I guarantee it will be way less than$1000.