cancel
Showing results for 
Search instead for 
Did you mean: 

ST32F4: DRAM throughput

michaelmichael9
Associate
Posted on August 14, 2015 at 01:31

Hi all

I use the STM32429I-EVAL1 board and I did some memory performance measurements (no DMA). The results were a bit strange, as writing to memory is about 50% faster than reading:

@180MHz 

            write mbs/read mbs            

byte        28.57/14.67     

word        136.89/53.05    

I suspect the memory init code has some errors - for example it doesn't matter what option I use for the burst mode. My init Code looks like this:

  sdramHandle.Init.SDBank             = FMC_SDRAM_BANK1;

  sdramHandle.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;

  sdramHandle.Init.CASLatency         = FMC_SDRAM_CAS_LATENCY_2;

  sdramHandle.Init.WriteProtection    = FMC_SDRAM_WRITE_PROTECTION_DISABLE;

  sdramHandle.Init.SDClockPeriod      = FMC_SDRAM_CLOCK_PERIOD_2;

  sdramHandle.Init.ReadBurst          = FMC_SDRAM_RBURST_ENABLE;

  sdramHandle.Init.ReadPipeDelay      = FMC_SDRAM_RPIPE_DELAY_0;

  sdramHandle.Init.ColumnBitsNumber   = FMC_SDRAM_COLUMN_BITS_NUM_9;

  sdramHandle.Init.RowBitsNumber      = FMC_SDRAM_ROW_BITS_NUM_12;

  sdramHandle.Init.MemoryDataWidth    = FMC_SDRAM_MEM_BUS_WIDTH_32;

void BSP_SDRAM_Initialization_sequence(uint32_t RefreshCount)

{

  __IO uint32_t tmpmrd = 0;

  /* Step 1: Configure a clock configuration enable command */

  Command.CommandMode            = FMC_SDRAM_CMD_CLK_ENABLE;

  Command.CommandTarget          = FMC_SDRAM_CMD_TARGET_BANK1;

  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) */

  cyg_thread_delay(1);

  /* Step 3: Configure a PALL (precharge all) command */

  Command.CommandMode            = FMC_SDRAM_CMD_PALL;

  Command.CommandTarget          = FMC_SDRAM_CMD_TARGET_BANK1;

  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_BANK1;

  Command.AutoRefreshNumber      = 8;

  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_4          |\

                     SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL   |\

                     SDRAM_MODEREG_CAS_LATENCY_2           |\

                     SDRAM_MODEREG_OPERATING_MODE_STANDARD |\

                     SDRAM_MODEREG_WRITEBURST_MODE_SINGLE;

  Command.CommandMode            = FMC_SDRAM_CMD_LOAD_MODE;

  Command.CommandTarget          = FMC_SDRAM_CMD_TARGET_BANK1;

  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);

}

Do you have a clue what could be wrong? 

BR

Michael

#dram-throughput
1 REPLY 1
stm322399
Senior
Posted on August 14, 2015 at 10:29

There could be tens of reasons for that.

How do you get that numbers ? Does the same benchmark returns similar results with the various internal SRAM banks ?

Write boost could come from to the effect of the write buffer of the Cortex-M4. Buffering writes gives tremendous bandwidth upgrade particularly with SDRAM. Try to test with write buffer disabled, set bit DISDEFWBUF in ACTLR register from CM4.