cancel
Showing results for 
Search instead for 
Did you mean: 

How to use external SDRAM with STM32H747

Son, Dong-Seong
Associate III

Hi.

I am test external SDRAM with STM32H747.

SDRAM chip is IS42S8640D-7TLI

I set SDRAM1 in FMC of Connectivity as followed

0693W00000Y8A3MQAV.pngClock and chip enable : SDCKE1+SDNE1

internal bank number : 4 banks

Address 13bits

DAta 8 bits

number of column address bits : 10 bits

number of row address bits : 13 bits

After I generate code,

'SystemInit_ExtMemCtl(void)' is not in sytem_stm32h7xx_dualcore_boot_cm4_cm7.c

​The function is not anywhere.

Other example project for SDRAM has the function

What should i do more?

I added this code for testing SDRAM as below

/* USER CODE BEGIN 4 */

#define SDRAM_ADD 0xd0000000

uint8_t wdata[] = {0x1, 0x2, 0x3, 0x4, 0x5};

uint8_t rdata[10];

/* USER CODE END 4 */

void StartDefaultTask(void const * argument)

{

  /* init code for USB_DEVICE */

  MX_USB_DEVICE_Init();

  /* USER CODE BEGIN 5 */

  vAppCmdTaskInit();

  int cnt=0;

  memcpy((uint32_t *) SDRAM_ADD, wdata, 5);

  memcpy(rdata, (uint32_t *) SDRAM_ADD, 5);

  /* Infinite loop */

  for(;;)

  {

   osDelay(1000);

   HAL_GPIO_TogglePin(GPIOI, GPIO_PIN_7);

   printf("Hello CDC Test %4d\r\n", cnt++);

  }

  /* USER CODE END 5 */

}

After compiling, in debug mode

when excute memcpy((uint32_t *) SDRAM_ADD, wdata, 5);

It occurs Hard fault.

Could anyone let me know how to set external SDRAM and fix my mistakes?

please help me..

1 REPLY 1
Ghofrane GSOURI
ST Employee

Hello @Son, Dong-Seong​ 

First let me thank you for posting.

It appears that there is an issue with the way you are trying to access the external SDRAM. The 'memcpy' function is used to copy data from one memory location to another, but it is not designed to initialize or configure the SDRAM. The 'memcpy' function is also assuming that the memory location is valid and accessible, which may not be the case for the external SDRAM.

In order to properly initialize and configure the external SDRAM, you will need to use the appropriate functions provided by the STM32H747 firmware library.

The 'SystemInit_ExtMemCtl(void)' function that you mentioned in your previous question is typically used for this purpose.

So try to add this function manually in your code .

You should also check the SDRAM's data sheet and the STM32H747's reference manual for more information about how to properly configure the SDRAM. 

The SDRAM's data sheet will provide information about the timings and commands required to initialize the SDRAM and the reference manual will give you information about the registers and functions that are needed to configure the SDRAM.

It's also important to check the memory address you are writing to, as it may not be in the correct range.

Additionally, you should check the SDRAM's datasheet to ensure that you are providing the correct timing parameters,

such as the load mode register to active delay and the exit self-refresh delay. If the values you have set do not match the specifications in the datasheet, it could cause issues when trying to access the SDRAM.

In summary, it is important to use the correct initialization function ,

consult the SDRAM's datasheet and the microcontroller's reference manual and make sure that the memory address is correct and the timings are set correctly.

Try this solution and I will be waiting for your feedback 

Thx

Ghofrane