cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 SDRAM IS42S16320F-7, Mem Viewer Works, But Code Generates Mem Access Violations

BComp
Associate

I am working with a new design which includes a STM32H7A3IGT6 with a connected SDRAM, IS42S16320F-7.

I've followed advice from this article:

https://community.st.com/s/article/How-to-set-up-the-FMC-peripheral-to-interface-with-the-SDRAM-IS42S16800F-6BLI-from-ISSI

When I pause the program after initialization, I can use the memory viewer to view and modify memory at 0xC0000000 with no issues. However, when I hit any code that attempts to view or modify that same memory range I get a memory fault.

CFSR shows MMARVALID and DACCVIOL. MMFAR points to 0xC0000000.

Here is my configuration:

0693W00000bhDf6QAE.png0693W00000bhDfBQAU.png 

SDRAM Init Function:

/**
  * @brief  Perform the SDRAM external memory initialization sequence
  * @param  hsdram: SDRAM handle
  * @param  Command: Pointer to SDRAM command structure
  * @retval None
  */
static void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command)
{
  volatile HAL_StatusTypeDef result;
  __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 */
  result = HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
 
  /* Step 2: Insert 100 us minimum delay */
  /* Inserted delay is equal to 1 ms due to systick time base unit (ms) */
  HAL_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 */
  result |= HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
 
  /* Step 4 : 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 */
  result |= HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
 
  /* Step 5: Program the external memory mode register */
  tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1          |
                     SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL   |
                     SDRAM_MODEREG_CAS_LATENCY_3           |
                     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 */
  result |= HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
 
  /* Step 6: Set the refresh rate counter */
  /* Set the device refresh rate
  * COUNT = [(SDRAM self refresh time / number of row) x  SDRAM CLK] – 20*/
  result |= HAL_SDRAM_ProgramRefreshRate(hsdram, REFRESH_COUNT);
}
#define SDRAM_TIMEOUT                    ((uint32_t)0xFFFF)
#define REFRESH_COUNT                    ((uint32_t)400)   /* SDRAM refresh counter */

 0693W00000bhDfpQAE.png 

Any help would be appreciated. Thanks!

0 REPLIES 0