HAL library 11- SDRAM for STM32Fxxx

SDRAM library was designed to be used on STM32F429-Discovery, STM32F439-EVAL and STM32F7-Discovery boards. With single define, library will know which board is used and which settings should use to get proper working for RAM.

FMC peripheral is used for driving SDRAM.


Read more about new HAL libraries


  • Use SDRAM on STM32F429-Discovery board
  • Use SDRAM on STM32F439-EVAL board
  • Use SDRAM on STM32F7-Discovery board
  • Supports custom pins initialization in case user has own board with RAM
  • Supports commands for read and write different types of numbers


  • HAL
  • TM
    • STM32Fxxx HAL
    • defines.h
    • attributes.h
    • TM GPIO

Board pinouts

SDRAM pins are different for different board. Using proper defines (explained below) you can select which board is used.

For full pinout list, download and open SDRAM library and check header file with description.

Select board

The most important thing is to tell library, which board is used in target system. There are 2 possible ways to do that. One (and I prefer it) is to check my DISCO library and follow instructions which define you have to set for proper board, and another, explained below.

If you choose option one, then you will have no worries in my future libraries where library needs to know exactly which board is used!

The second option (I don’t prefer it) is, to set define only for this library. Copy define corresponding to your board into defines.h file or make a global defines in compiler’s settings. I made global defines in Keil uVision under “Options for Target” -> “C/C++” tab.

Functions and enumerations


Project is available in Github, download all libraries below.


Owner of this site. Also electronic enthusiasts, web developer, 3D printer fan, handball player and more. Big fan of STM32F4 devices. In anticipation of the new Discovery board for STM32F7 lines.

You may also like...

Read before commenting!

Before you make a new comment, make sure you agree with things listed below:

  • - Read post to make sure if it is already posted what you are asking for,
  • - Make sure you have the latest version of libraries used in your project,
  • - Make a clean and grammatically correct written message,
  • - Report as many details as possible, including what have you done so far,
  • - Do NOT post any code here. Use Pastebin,
  • - Do NOT post any error codes here. Use Pastebin,
  • - Specify STM32Fxxx family and used Discovery/EVAL/Nucleo or custom made board,
  • - Make sure your clock is set correct for PLL,
  • - If you are using my HAL drivers, please check this post how to start.
Comment will be deleted on breaking these rules without notification!
  • Murtaz Naqvi

    Is it possible to interface DDR Ram with STM32Fxxx????

    • Just calmdown! If ddrram supports fmc then easily!

  • Murtaz Naqvi

    The frequency of ddr ram is 333 and that of stm32 is 180 hz .will it create any difficulties in it interfacing ?

    • F4 can control RAM with up to 90MHz clock. Why you actually need DDR ram?

      • Murtaz Naqvi

        Actually we are making an e-reader using stm32f4xxxxx . So can you guide us how much (w.r.t capacity ) can we use. And the sdram interfaced with stm32f429 board is working on 143mhz or 166mhz.

        • Yeah? 143 and 166MHz clock is used? How, your F429 works on 300+ MHz then? 😀

  • Murtaz Naqvi

    Is this necessary to equalize both the frequencies b4 interfacing?

  • Pingback: All STM32 HAL libraries - STM32F4 Discovery()

  • Preity

    Has anyone tried writing a float value to SDRAM with these libraries. My code gets stuck when I use :
    TM_SDRAM_WriteFloat(address, value) ;
    I am able to read/write uint8_t, uint16_t and uint32_t, just not float. Any ideas?

    • You get hard-fault error?
      For me, it always worked OK.

      • Preity

        But if I try writing an uint32_t to the same address it works fine !