cancel
Showing results for 
Search instead for 
Did you mean: 

Hardfault when trying to access SDRAM on STM32h745i-DISCO

MARTIN LAZZARI
Associate II

I am trying to wire a graphics application on an STM32H745i-DISCO board, and place the framebuffer in external SDRAM.

So I configured the FMC as follows:

MARTINLAZZARI_0-1723238752657.pngMARTINLAZZARI_1-1723238780457.pngMARTINLAZZARI_2-1723238797538.png

Then, under Cortex-M7 I set up the MPU:

MARTINLAZZARI_3-1723238954501.png

But when running the program and attempting to write to 0xD000 0000 I get a hard fault.

What am I missing?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Still, the initialization code for the SDRAM is chip-dependent, so I had to add the proper initialization code. This can be found in the BSP (board support package) drivers for the STM32H745i-DISCO.

Here's an article on how to import the BSP into an existing project:

https://community.st.com/t5/stm32-mcus/how-to-add-a-bsp-to-an-stm32cubeide-project/ta-p/49812

Essentially, create a new project for the board that you are using, and import the files from the BSP folder. In this case, the files for the sd_ram and its specific component (MT48LC4M32B2). Once you add your files to your sources and include path, you can add the call to the initialization.

At the end of the MX_FMC_Init function, call the initialization function for the specific SDRAM:

 

/* USER CODE BEGIN FMC_Init 2 */

if (BSP_SDRAM_Init(0) != BSP_ERROR_NONE)

{

Error_Handler();

}

/* USER CODE END FMC_Init 2 */

 

View solution in original post

2 REPLIES 2
MARTIN LAZZARI
Associate II

OK, I added some initialization code for the SDRAM copied from here:

https://community.st.com/t5/stm32-mcus/how-to-set-up-the-fmc-peripheral-to-interface-with-the-sdram/ta-p/49457

and now I'm no longer getting a hardafult

 

Still, the initialization code for the SDRAM is chip-dependent, so I had to add the proper initialization code. This can be found in the BSP (board support package) drivers for the STM32H745i-DISCO.

Here's an article on how to import the BSP into an existing project:

https://community.st.com/t5/stm32-mcus/how-to-add-a-bsp-to-an-stm32cubeide-project/ta-p/49812

Essentially, create a new project for the board that you are using, and import the files from the BSP folder. In this case, the files for the sd_ram and its specific component (MT48LC4M32B2). Once you add your files to your sources and include path, you can add the call to the initialization.

At the end of the MX_FMC_Init function, call the initialization function for the specific SDRAM:

 

/* USER CODE BEGIN FMC_Init 2 */

if (BSP_SDRAM_Init(0) != BSP_ERROR_NONE)

{

Error_Handler();

}

/* USER CODE END FMC_Init 2 */