cancel
Showing results for 
Search instead for 
Did you mean: 

stm32cubemx init SDRAM in STM32F429NI

drachev
Associate II
Posted on March 03, 2016 at 07:28

Hello.

CubeMX not correct settings SDRAM, when use 2 chip.

CubeMX create next not work code:

/* FMC initialization function */

void MX_FMC_Init(void)

{

  FMC_SDRAM_TimingTypeDef SdramTiming;

  /** Perform the SDRAM1 memory initialization sequence

  */

  hsdram1.Instance = FMC_SDRAM_DEVICE;

  /* hsdram1.Init */

  hsdram1.Init.SDBank = FMC_SDRAM_BANK1;

  hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9;

  hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13;

  hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16;

  hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;

  hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3;

  hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;

  hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2;

  hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE;

  hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_1;

  /* SdramTiming */

  SdramTiming.LoadToActiveDelay = 2;

  SdramTiming.ExitSelfRefreshDelay = 7;

  SdramTiming.SelfRefreshTime = 4;

  SdramTiming.RowCycleDelay = 7;

  SdramTiming.WriteRecoveryTime = 3;

  SdramTiming.RPDelay = 2;

  SdramTiming.RCDDelay = 2;

  HAL_SDRAM_Init(&hsdram1, &SdramTiming);

  /** Perform the SDRAM2 memory initialization sequence

  */

  hsdram2.Instance = FMC_SDRAM_DEVICE;

  /* hsdram2.Init */

  hsdram2.Init.SDBank = FMC_SDRAM_BANK2;

  hsdram2.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9;

  hsdram2.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13;

  hsdram2.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16;

  hsdram2.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;

  hsdram2.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3;

  hsdram2.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;

  hsdram2.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2;

  hsdram2.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE;

  hsdram2.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_1;

  /* SdramTiming */

  SdramTiming.LoadToActiveDelay = 2;

  SdramTiming.ExitSelfRefreshDelay = 7;

  SdramTiming.SelfRefreshTime = 4;

  SdramTiming.RowCycleDelay = 7;

  SdramTiming.WriteRecoveryTime = 3;

  SdramTiming.RPDelay = 2;

  SdramTiming.RCDDelay = 2;

  HAL_SDRAM_Init(&hsdram2, &SdramTiming);

}

Need befor Init sdram2, then init sdram1.

Next cod is work:

/* FMC initialization function */

void MX_FMC_Init(void)

{

  FMC_SDRAM_TimingTypeDef SdramTiming;

  

  /** Perform the SDRAM2 memory initialization sequence

  */

  hsdram2.Instance = FMC_SDRAM_DEVICE;

  /* hsdram2.Init */

  hsdram2.Init.SDBank = FMC_SDRAM_BANK2;

  hsdram2.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9;

  hsdram2.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13;

  hsdram2.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16;

  hsdram2.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;

  hsdram2.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3;

  hsdram2.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;

  hsdram2.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2;

  hsdram2.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE;

  hsdram2.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_1;

  /* SdramTiming */

  SdramTiming.LoadToActiveDelay = 2;

  SdramTiming.ExitSelfRefreshDelay = 7;

  SdramTiming.SelfRefreshTime = 4;

  SdramTiming.RowCycleDelay = 7;

  SdramTiming.WriteRecoveryTime = 3;

  SdramTiming.RPDelay = 2;

  SdramTiming.RCDDelay = 2;

  HAL_SDRAM_Init(&hsdram2, &SdramTiming);

  

  /** Perform the SDRAM1 memory initialization sequence

  */

  hsdram1.Instance = FMC_SDRAM_DEVICE;

  /* hsdram1.Init */

  hsdram1.Init.SDBank = FMC_SDRAM_BANK1;

  hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_9;

  hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13;

  hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16;

  hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;

  hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3;

  hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;

  hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2;

  hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE;

  hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_1;

  /* SdramTiming */

  SdramTiming.LoadToActiveDelay = 2;

  SdramTiming.ExitSelfRefreshDelay = 7;

  SdramTiming.SelfRefreshTime = 4;

  SdramTiming.RowCycleDelay = 7;

  SdramTiming.WriteRecoveryTime = 3;

  SdramTiming.RPDelay = 2;

  SdramTiming.RCDDelay = 2;

  HAL_SDRAM_Init(&hsdram1, &SdramTiming);

}

I hope you resolve the problem and make a little better cubeMX.
2 REPLIES 2
Amel NASRI
ST Employee
Posted on March 08, 2016 at 10:14

Hi drachev.andrei,

Your case is reported internally for further investigation.

You will be updated if there are more details to add on this regard.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

stm32cube-t
Senior III
Posted on March 18, 2016 at 09:21

Dear user,

Thank you for reporting this issue. Your workaround is correct.

The root cause has been found in the HAL driver implementation and shall be fixed a.s.a.p.:

The SDRAM2 configuration is clearing the whole configuration of bank1 when it should only take care of the parameters for both banks(clock period, burst...): these parameters are configured in SDCR1 register.

Best regards