2026-04-14 12:10 AM - edited 2026-04-14 3:36 AM
Hi all,
I am working with STM32F469ZIT6 and external SDRAM AS4C4M16SA-6TIN SDRAM using FMC (Bank1).
Setup
SDRAM clock has been verified using an oscilloscope and matches expected frequencies.
Test Code
I am writing a pattern to SDRAM and reading it back:
- Write pattern: `0xA1234567 + index`
- Base address: `0xC0000000`
for (uwIndex = 0; uwIndex < BUFFER_SIZE; uwIndex++)
{
*(__IO uint32_t*) (SDRAM_BANK_ADDR + WRITE_READ_ADDR + 4*uwIndex) = aTxBuffer[uwIndex];
}Read back:
for (uwIndex = 0; uwIndex < BUFFER_SIZE; uwIndex++)
{
aRxBuffer[uwIndex] = *(__IO uint32_t*) (SDRAM_BANK_ADDR + WRITE_READ_ADDR + 4*uwIndex);
}
- The read operation does not return the correct written data
- Instead:
Initialization Sequence
static void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram, FMC_SDRAM_CommandTypeDef *Command)
{
__IO uint32_t tmpmrd =0;
/* Step 3: 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 */
HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
/* Step 4: Insert 200uS delay */
HAL_Delay(1);
/* Step 5: 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 */
HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
/* Extended Mode Register Set — required for AS4C4M16SA (drive strength: Full = A1=0) */
Command->CommandMode = FMC_SDRAM_CMD_LOAD_MODE;
Command->CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
Command->AutoRefreshNumber = 1;
Command->ModeRegisterDefinition = 0x0000; /* Extended MRS: BA0=1 drives bank select; Full drive strength */
HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
/* Program the external memory mode register */
tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1 |
SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL |
SDRAM_MODEREG_CAS_LATENCY_2 |
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 */
HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
/* Step 6 : 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 */
HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
HAL_Delay(1);
/* Step 6 : 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 */
HAL_SDRAM_SendCommand(hsdram, Command, SDRAM_TIMEOUT);
/* Step 8: Set the refresh rate counter */
/* (15.62 us x Freq) - 20 */
/* Set the device refresh counter */
HAL_SDRAM_ProgramRefreshRate(hsdram, REFRESH_COUNT);
}Observations
Same behavior across:
Questions
Attached Files
Full project files are attached (FMC config + test code):
Any insights or debugging suggestions would be greatly appreciated.
Thanks in advance!
Solved! Go to Solution.
2026-05-08 3:03 AM
Issue resolved.
After reviewing the STM32F469 errata sheet, it was identified that PA7 does not support the FMC_SDNWEN alternate function. However, during code generation, PA7 was configured for FMC_SDNWEN, which was misleading.
After reconfiguring FMC_SDNWEN to a valid pin as mentioned in the errata sheet, the SDRAM started working correctly.
Attached the errata reference image for clarity.
2026-04-14 2:10 AM
Hello,
Attached FilesFull project files are attached (FMC config + test code):
Just to warn you that there is nothing attached to your post.
2026-04-14 3:32 AM - edited 2026-04-14 3:36 AM
2026-05-08 3:03 AM
Issue resolved.
After reviewing the STM32F469 errata sheet, it was identified that PA7 does not support the FMC_SDNWEN alternate function. However, during code generation, PA7 was configured for FMC_SDNWEN, which was misleading.
After reconfiguring FMC_SDNWEN to a valid pin as mentioned in the errata sheet, the SDRAM started working correctly.
Attached the errata reference image for clarity.
2026-05-08 3:11 AM
Hello,
Thank you for the update.
@Shubha_99 wrote:
However, during code generation, PA7 was configured for FMC_SDNWEN, which was misleading.
Could you please share your ioc file on which PA7 is enabled for FMC_SDNWEN by CubeMx by default?
2026-05-08 3:34 AM
Hello,
I am currently unable to share the .ioc file, but the issue can be reproduced with the following steps:
After enabling FMC, PA7 gets assigned for FMC_SDNWE.
Thank you for the support.
2026-05-08 3:35 AM - edited 2026-05-08 3:39 AM
You can share with me the ioc file in private. So we could analyze from our side.
When I've enabled the FMC_SDRAM, PA7 is not active: