cancel
Showing results for 
Search instead for 
Did you mean: 

stm32cubemx & SDRAM initialization

mnavahan3
Associate
Posted on April 20, 2016 at 18:08

Hi

I use current stm32cubemx & cubef4 1.11

i set in cubemx pins , clock & SDRAM config and generate code

when i see sdram initialize code seems it not set auto refresh commands

then configuration of sdram in cubemx not generate all configuration need by sdram such as refresh ?

 

#scram-cubemx
2 REPLIES 2
Nesrine M_O
Lead II
Posted on April 21, 2016 at 18:50

Hi navahan.maziar.001,

  • I generate code with MX 4.14 & cube F4 1.0 and I have the code bellow for FMC initialization:

/* FMC initialization function */
void

MX_FMC_Init(

void

)
{
FMC_SDRAM_TimingTypeDef SdramTiming;
…
/* SdramTiming */
SdramTiming.LoadToActiveDelay = 16;
SdramTiming.ExitSelfRefreshDelay = 16;
SdramTiming.SelfRefreshTime = 16;
SdramTiming.RowCycleDelay = 16;
SdramTiming.WriteRecoveryTime = 16;
SdramTiming.RPDelay = 16;
SdramTiming.RCDDelay = 16;
…
}

These parameters initialize the SDRAM timing Interface such us Self Refresh period, delay between a Load Mode Register command and an active or Refresh command. These parameters can be a value between Min_Data = 1 and Max_Data = 16 configurable from the FMC configuration window.
  • I recommend you also to have a look to the FMC running examples under the STM32F4 cube firmware package:STM32Cube_FW_F4_V1.0\Projects\STM324x9I_EVAL\Examples\FMC\FMC_SDRAM
-Syrine-
mnavahan3
Associate
Posted on April 22, 2016 at 04:55

yes it generate :

simple setting of mcu sdram section But really after it sdram work ? it forget set internal sdram refresh command :

Command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE;
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;
Command.AutoRefreshNumber = 1;
Command.ModeRegisterDefinition = 0;
/* Send the command */
HAL_SDRAM_SendCommand(&SdramHandle, &Command, SDRAM_TIMEOUT);
/* Step 2: Insert 100 us minimum delay */
/* Inserted delay is equal to 1 ms due to systick time base unit (ms) */
HAL_Delay(1);
/* Step 3: Configure a PALL (precharge all) command */
Command.CommandMode = FMC_SDRAM_CMD_PALL;
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;
Command.AutoRefreshNumber = 1;
Command.ModeRegisterDefinition = 0;
/* Send the command */
HAL_SDRAM_SendCommand(&SdramHandle, &Command, SDRAM_TIMEOUT); 
/* Step 4: Configure an Auto Refresh command */
Command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE;
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;
Command.AutoRefreshNumber = 4;
Command.ModeRegisterDefinition = 0;
/* Send the command */
HAL_SDRAM_SendCommand(&SdramHandle, &Command, SDRAM_TIMEOUT);
/* Step 5: Program the external memory mode register */
tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_2 |
SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL |
SDRAM_MODEREG_CAS_LATENCY_3 |
SDRAM_MODEREG_OPERATING_MODE_STANDARD |
SDRAM_MODEREG_WRITEBURST_MODE_SINGLE;
Command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE;
Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2;
Command.AutoRefreshNumber = 1;
Command.ModeRegisterDefinition = tmpmrd;
/* Send the command */
HAL_SDRAM_SendCommand(&SdramHandle, &Command, SDRAM_TIMEOUT);
/* Step 6: Set the refresh rate counter */
/* Set the device refresh rate */
HAL_SDRAM_ProgramRefreshRate(&SdramHandle, RefreshCount); 

1. minimum if user must do it manual it must notify it

2. also i confused with

DATA_IN_ExtSRAM in

system_stm32f4xx.c

if try use

DATA_IN_ExtSRAM

what happen for my HAL setting ??

and must manually set config GPIO & sdram config in

system_stm32f4xx.c

again ???? why st driver not used same value in HAL & CMSIS ???