TrueStudio and CubeMX external SDRAM setup

Discussions concerning TrueSTUDIO for STM32 9.0.0 and later versions.

Moderators: Markus Girdland, Mattias Norlander

TheGrovesy
Posts: 1
Joined: Tue Jul 10, 2018 2:09 pm

TrueStudio and CubeMX external SDRAM setup

Postby TheGrovesy » Tue Jul 10, 2018 2:11 pm

I have the STM32F746G Discovery board and used CubeMX to generate the TrueStudio project for this. Out of the box CubeMX already has a project for this board with all paripherals already setup, including external SDRAM. However the generated truestudio project does not appear to set the SDRAM fully to utilise it!

There are calls generated for MX_FMC_Init() which in turn calls the function HAL_SDRAM_Init() but when you debug there is no region appearing in the build analyzer. I have been reading that this must be defined in the .ld file so I have added it so it now looks like this:

MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 320K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K
SDRAM (rx) : ORIGIN = 0xC0000000, LENGTH = 16M
}

which now shows a region in the build analyzer called SDRAM but my write/reads to any address over 0xC0000000 are still failing and using the memory watch window it cannot show any memory in that region and just shows ????.

What am I missing? Any clues would be great.

Dandjinh
Posts: 5
Joined: Tue Apr 17, 2018 2:38 am

Re: TrueStudio and CubeMX external SDRAM setup

Postby Dandjinh » Thu Jul 12, 2018 9:23 am

You have to do some extra work for SDRAM. The function below is copied from "STM32Cube_FW_F7_V1.11.0\Projects\STM32746G-Discovery\Examples\FMC\FMC_SDRAM\Src\main.c"

Code: Select all

static void BSP_SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command)
{
  __IO uint32_t tmpmrd =0;
  /* Step 3:  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(hsdram, Command, SDRAM_TIMEOUT);

  /* Step 4: Insert 100 us minimum delay */
  /* Inserted delay is equal to 1 ms due to systick time base unit (ms) */
  HAL_Delay(1);

  /* Step 5: 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(hsdram, Command, SDRAM_TIMEOUT);

  /* Step 6 : Configure a 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(hsdram, Command, SDRAM_TIMEOUT);

  /* Step 7: Program the external memory mode register */
  tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1          |
                     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(hsdram, Command, SDRAM_TIMEOUT);

  /* Step 8: Set the refresh rate counter */
  /* (15.62 us x Freq) - 20 */
  /* Set the device refresh counter */
  hsdram->Instance->SDRTR |= ((uint32_t)((1292)<< 1));

}


Return to “TrueSTUDIO for STM32 discussions”

Who is online

Users browsing this forum: Bing [Bot] and 0 guests