cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX V1.1.0 + SDRAM

malcolm23
Associate III
Posted on April 25, 2014 at 03:35

Greetings all,

I'm trying to use STM32CubeMX to build a configuration for the EMCraft STM32F4 SOM. In trying to get the SDRAM functional and I believe I have the settings correct; however it looks like the generated code configures the SDRAM but never issues any commands to start it.

I was poking around the STM32Cube_FW_F4_V1.1.0 files and found stm32f429i_discovery_sdram.c which contains the BSP_SDRAM_Initialization_sequence function that actually commands the SDRAM to start.

I'm curious now what parts of initialization STM32CubeMX does, and what parts it leaves for the developer to implement. Should I need to write a function equivalent to BSP_SDRAM_Initialization_sequence, or should STM32CubeMX emit one and I've just missed a checkbox somewhere.

Many thanks,

- Malcolm
5 REPLIES 5
Posted on April 25, 2014 at 04:23

Well in the CMSIS model the external memory is typically configured/initialized in SystemInit() (system_stm32f4xx.c) which is called prior to the execution of the C runtime library startup code (zeros/copies statics)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stm322399
Senior
Posted on April 25, 2014 at 07:58

Using the 'old' st peripheral lib, I am suppose the 'cube' does has the same paradigm:

SystemInit() will init the SDRAM only when you define DATA_IN_ExtSDRAM, which is intended to configure your project for using SDRAM for the data segment (variables, heap, stack).

If you use SDRAM as a big array of bytes for your application (e.g. to store data captured from DCMI, or Ethernet, or as LCDC frame buffer), it up to you to call an initialisation routine, hence the file stm32f429i_discovery_sdram.c

malcolm23
Associate III
Posted on April 26, 2014 at 04:34

I'm familar with the CMSIS startup, but at this time I don't have any data loading into SDRAM so I don't need to migrate the code that far back into the startup process. I'm more interested in finding whether the SDRAM settings I pick in STM32CubeMX are correct. Currently STM32CubeMX produces a main function which does the following:

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

  HAL_Init();

  /* Configure the system clock */

  SystemClock_Config();

  /* Initialize all configured peripherals */

  MX_GPIO_Init();

  MX_FMC_Init();

  MX_RNG_Init();

Specifically the MX_FMC_Init() configures the FMC settings I selected in STM32CubeMX with regards to SDRAM configurations - bank, pins, etc. (I also have the NOR-Flash configured in here, and it looks like it's finding the EMCraft boards 16MB NOR chip correctly)

I'm just curious if the MX_FMC_Init() function isn't enabling the SDRAM because I forgot to check something off; or if STM32CubeMX doesn't consider enabling the SDRAM as something it's responsible to generate the code for.

Many thanks,

 - Malcolm

Posted on April 26, 2014 at 05:35

SDRAM initialization is clearly highly dependent on the specific chip(s) being attached, Row, Columns, Banks, RAS, CAS, Refresh, etc. I'd punt that to the BSP if I could...

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
malcolm23
Associate III
Posted on April 26, 2014 at 18:05

Agreed - and in fact those are the values I'm trying to nail down using STM32CubeMX to build test applications. It seems like all (or most?) of the values have fields in STM32CubeMX, so it seems likely it has all the information to correctly bring up the SDRAM within the MX_FMC_Init() routine.

0690X00000605eeQAA.png