cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 SDRAM Write or Read Operation Is Not Executing Properly

ÇSerp.1
Associate II
I am using STM32F469BIT6 on a custom PCB with IS42S16400J-7TLI external 8Mb SDRAM. On my previous board, I was using STM32F429ZIT6 with the same SDRAM (these mcu&sdram selected because they were used in STM32F429-DISCO) I was able to write/read data to/from SDRAM with these settings:
Serp1_0-1738737355577.png

 

When I try the same settings with the new MCU (STM32F469BIT6) on the new PCB, I can write to / read from SDRAM but data is corrupted. Here's the code that I use to test my SDRAM:

 

/* USER CODE BEGIN PV */
volatile uint8_t *externalRAM = (uint8_t*) 0xC0000000;
const uint32_t size = 8 * 1024 * 1024; //8MB
/* USER CODE END PV */
/* USER CODE BEGIN 2 */
//write external RAM
for (uint32_t i = 0; i < size; i++) {
externalRAM[i] = i % 256;
}

//read external RAM
for (uint32_t i = 0; i < size; i++) {
if (externalRAM[i] != i % 256) {
asm("nop");
// insert error handling logic here
}
}
/* USER CODE END 2 */

 

 
Here's SDRAM Configuration Code:

 

	/* USER CODE BEGIN FMC_Init 2 */
	FMC_SDRAM_CommandTypeDef Command;
	/* Step 1 and Step 2 already done in HAL_SDRAM_Init() */
	/* Step 3: Configure a clock configuration enable command */
	Command.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE; /* Set MODE bits to "001" */
	Command.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK2; /* configure the Target Bank bits */
	Command.AutoRefreshNumber = 1;
	Command.ModeRegisterDefinition = 0;
	HAL_SDRAM_SendCommand(&hsdram2, &Command, 0xfff);
	HAL_Delay(1); /* Step 4: Insert 100 us minimum delay - Min HAL Delay is 1ms */
	/* Step 5: Configure a PALL (precharge all) command */
	Command.CommandMode = FMC_SDRAM_CMD_PALL; /* Set MODE bits to "010" */
	HAL_SDRAM_SendCommand(&hsdram2, &Command, 0xfff);
	/* Step 6: Configure an Auto Refresh command */
	Command.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE; /* Set MODE bits to "011" */
	Command.AutoRefreshNumber = 2;
	HAL_SDRAM_SendCommand(&hsdram2, &Command, 0xfff);
	/* Step 7: Program the external memory mode register */
	Command.CommandMode = FMC_SDRAM_CMD_LOAD_MODE;/*set the MODE bits to "100" */
	Command.ModeRegisterDefinition = (uint32_t) 0 | 0 << 3 | 2 << 4 | 0 << 7
			| 1 << 9;
	HAL_SDRAM_SendCommand(&hsdram2, &Command, 0xfff);
	/* Step 8: Set the refresh rate counter - refer to section SDRAM refresh timer register in RM0455 */
	/* Set the device refresh rate
	 * COUNT = [(SDRAM self refresh time / number of row) x  SDRAM CLK] – 20
	 = [(64ms/4096) * 100MHz] - 20 = 1562.5 - 20 ~ 1542 */
	HAL_SDRAM_ProgramRefreshRate(&hsdram2, 1292); // 84MHZ
	/* USER CODE END FMC_Init 2 */

 

 
The problem is, when I try to write odd numbers (e.g. '1') to SDRAM, in the memory view, I see that all of the values are changed to "01". But when I try to write even numbers to SDRAM, only even addresses of SDRAM are changed to "02". This keeps happenning no matter the address or written data.
Serp1_1-1738737518277.png
Serp1_2-1738737529220.png
 
I can see clock generated on the oscilloscope:
Serp1_3-1738737546444.png

 

 
What might be the issue here? Any help would be much appreciated. 
0 REPLIES 0