2014-04-24 06:35 PM
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,- Malcolm2014-04-24 07:23 PM
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)
2014-04-24 10:58 PM
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.c2014-04-25 07:34 PM
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, - Malcolm2014-04-25 08:35 PM
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...
2014-04-26 09:05 AM
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.