cancel
Showing results for 
Search instead for 
Did you mean: 

Use of an external SDRAM (IS42S16320F) with STM32H753

Gregory3
Associate III

Hello!

I'm trying to use an external SDRAM (IS42S16320F) with an STM32H753 but no luck till now.

Could please anyone check if my settings are correct because I don't know if I made a bug here.

0693W000008yud1QAA.png 

0693W000008yudBQAQ.png0693W000008yudGQAQ.png 

For that I have attached the FMC configuration and the schematic parts with the SDRAM and uC.

I would be very greatefull for that.

Regards,

Gregor

11 REPLIES 11
Gregory3
Associate III

Hi!

Here some update for the topic.

I was trying to change the refresh rate according to the proposal to 400:

#define REFRESH_COUNT                    ((uint32_t)0x0190)   /* SDRAM refresh counter (100Mhz SD clock) */

which is set by the last step in the initialization function:

  /* Step 6: Set the refresh rate counter */
  /* Set the device refresh rate */
  HAL_SDRAM_ProgramRefreshRate(hsdram, REFRESH_COUNT);

that runs this one:

HAL_StatusTypeDef FMC_SDRAM_ProgramRefreshRate(FMC_SDRAM_TypeDef *Device, uint32_t RefreshRate)
{
  /* Check the parameters */
  assert_param(IS_FMC_SDRAM_DEVICE(Device));
  assert_param(IS_FMC_REFRESH_RATE(RefreshRate));
 
  /* Set the refresh rate in command register */
  MODIFY_REG(Device->SDRTR, FMC_SDRTR_COUNT, (RefreshRate << FMC_SDRTR_COUNT_Pos));
 
  return HAL_OK;
}

So it should set the SDRTR register to the value 0x0190.

After setting a breakpoint just after this function, the register has a value of 0x0:

0693W000008z2WIQAY.png 

Now I' checking why this is so, but this dosen't supose to look like this...

Gregory3
Associate III

Hello!

I have found the problem. The reason, why the register was not set, was very easy: I forgot to change in the SDRAM initialization function the number of the SDRAM to 2 (since I'm using the SDRAM2).

You can see here the sdramHandle is set to hsdram2 and everything works fine :)

void BSP_SDRAM_Init(void)
{
	sdramHandle = hsdram2;
 
    /* Program the SDRAM external device */
    SDRAM_Initialization_Sequence(&sdramHandle, &command);
 
 
}
 
 
/**
  * @brief  Perform the SDRAM external memory inialization sequence
  * @param  hsdram: SDRAM handle
  * @param  Command: Pointer to SDRAM command structure
  * @retval None
  */
void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command)
{
  __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_BANK2;;
  Command->AutoRefreshNumber = 1;
  Command->ModeRegisterDefinition = 0;
 
  /* Send the command */
  HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);

I have checked the registers and they are set now correctly.

I also wrote a simple code to do a first test:

  • fill Tx Buffer with some numbers
  • write Tx_Buffer to SDRAM starting at 0xD000 0000
  • read the SDRAM into a Rx_Buffer starting from 0xD000 0000

The result is fine in memory view and variable check:

0693W000008z9JLQAY.png0693W000008z9JQQAY.png

Thank you all for all the help!

Now I can continue to write my test code.

Regards,

Gregor