First time interfacing MCU with external SDRAM

Thread Starter

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?
 

WBahn

Joined Mar 31, 2012
29,976
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
21,158
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
30,706
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.
 

Thread Starter

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
30,706
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.
 

Thread Starter

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
21,158
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.
That must be some PCB, but large area and quantity one you might have to swallow some expense. I don't know what to tell you except maybe you should have quoted the job differently or refused it all together. Can you recover from the hit to your rep if you swing and miss?
 

bug13

Joined Feb 13, 2012
2,002
Just a thought, it may or may not help. Can you route to both CLK and !CLK pin with 0R resistor jumper? So end user can choose either one by loading the correct 0R resistor.
 

Thread Starter

TrackerFX

Joined May 18, 2020
13
@bug13
I think I need to have both hooked up for it to work correctly. I did some more research last night to see how the differential clock on the SDRAM works. DDR stands for Double Data Rate and works by allowing reading and writing to happen on both the rising edge and the falling edge of the clock cycle, hence the differential clock inputs; the DDR SDRAM reads/writes on the rising edge of `CLK` and the falling edge of `!CLK`. Older, non-DDR SDRAM just has a single clock input and I think it is more what is intended to be used in this type of application. Still, I wonder if I can send the same clock signal to both inputs and if the output clock speed of the MCU is even fast enough for DDR. This is going to take some more research but at least I got my answer as to the inverted clock input.

Thanks everyone!
 

Thread Starter

TrackerFX

Joined May 18, 2020
13
@Papabravo
I could probably take the hit if I thought it necessary but I'd rather stand on the shoulders of those who came before me and avoid re-inventing the wheel here. This is simply a case of ignorance on my part due to a lack of experience with external memory. I'm a quick study and should be able to figure this out, although it'd be faster if I could find someone with experience in interfacing with SDRAM. Can't always get what we want, though. I think I'm on the right track now and will post an update once I'm sure.
 

BobTPH

Joined Jun 5, 2013
8,806
Don’t know why someone would want a $1000 board for an app easily handled by a typical small PC at a far lower cost.

Bob
 

Thread Starter

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
21,158
**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
2,110
(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.
 

dendad

Joined Feb 20, 2016
4,451
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.
Also, I too stress, make a prototype!!!!!
Get the RAM running first. Make sure you have the bugs worked out and it really works before going to a production PCB.
 
Top