2026-02-03 3:17 PM - edited 2026-02-04 1:30 AM
Hi,
I want to fly the STM32F429I-DISC with the 8 MB SDRAM. I use CubeIDE and selected the right board. All units are set to default. I commented out everything that had to do with os.
With help of ChatGPT I hacked together an initialization of the SDRAM and set up a SDRAM Test. That seems to work partly but with weird effects. In the following code: start/end 0x00/0xff or 0x100/0x1ff works fine, but start/end 0x00/0x101 reads out 0x100 at address 0x0. Maybe it is an timing issue with precharged lines.
THX
Cheers
Detlef
#define SDRAM_BASE_ADDR ((uint32_t)0xD0000000)
void SDRAM_Test(void)
{
volatile uint16_t *p = (volatile uint16_t *)SDRAM_BASE_ADDR;
uint32_t i ;
uint32_t start = 0x100 ;
uint32_t end = 0x302 ;
for (i=start; i<end; i++) p[i] = i;
sprintf(buf,"start \r\n",i);
HAL_UART_Transmit(&huart1, (uint8_t *) buf, strlen(buf), HAL_MAX_DELAY);
while(1){
for (i=start; i<end;i++)
if (p[i] != i){
sprintf(buf,"no 0x%x 0x%x\r\n",i,p[i]);
HAL_UART_Transmit(&huart1, (uint8_t *) buf, strlen(buf), HAL_MAX_DELAY);
}
sprintf(buf,"end \r\n",i);
HAL_UART_Transmit(&huart1, (uint8_t *) buf, strlen(buf), HAL_MAX_DELAY);
}
}
Solved! Go to Solution.
2026-02-09 2:33 PM
Hi,
finally managed to run SDRAM and LCD on STM32F429I-DISC. There was no example for this for Cube IDE. The only working example ADC_DMA was 10y old and still for Attolic Studio, I did not want to work on that platform. I could not migrate the BSP-stuff to CubeIDE. I generated a static library from ADC_DMA and called SDRAM_InitSequence() and LCD_Init() . That finally worked.
I would have wished a working SDRAM and LCD example for CubeIDE and more support on my lonely way through the #define jungle e.g. PIN versus Pin.
Cheers
Detlef
2026-02-04 12:36 AM - edited 2026-02-04 12:36 AM
Hello,
1- In next time please use </> to share a code. Please read How to write your question to maximize your chances to find a solution
I invite you to edit your post to comply with the rule.
Thank you for your understanding.
2- Better to inspire from the SDRAM driver implemented in the BSP : https://github.com/STMicroelectronics/32f429idiscovery-bsp/blob/d77779a2a4e950246752a4397e2adf40c25829f9/stm32f429i_discovery_sdram.c
2026-02-04 2:01 AM
I never had a F429 Disco board.
However, I believe to remember it was around the time the first boards were "blessed" with Cube/HAL code instead of the legacy SPL.
I recommend to check if a SPL-based firmware package is available, those always contained driver or example code for onboard peripherals or units like SDRAMs, LCDs, MEMS or audio codecs.
And the SPL is much less awkward and easier to understand.
And even if you choose a new Cube-based example, the config settings of the SPL code can serve as a template.
2026-02-04 9:19 AM - last edited on 2026-02-04 9:38 AM by Andrew Neil
Merged into existing thread
Hi,
I loaded the discovery board with the default CubeIDE project for that board. FMC and SDRAM are enabled, HAL_SDRAM_GetState(&hsdram1) returns ready. If I want to read or write SDRAM at address 0xC0000000 or 0xD0000000 the program freezes.
What do I miss?
THX Cheers
Detlef
2026-02-05 10:11 AM
The default project on CubeIDE for the STM32F429I-DISC board both enables FMC and SDRAM. The SDRAM_Initialization_Sequence was missing. With this sequence it is possible to read and write the SDRAM.
But: In a complete Test of all 0x400000 16Bit words I always see 3-6 faults. The default STM project for the board should be ok, so the problem is in SDRAM_Initialization_Sequence.
THX for a hint
Cheers Detlef
/**********************************************************************/
static void SDRAM_Initialization_Sequence(SDRAM_HandleTypeDef *hsdram)
/**********************************************************************/
{
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/* Refresh-Count: abhängig von SDCLK!
Formel: count = (tREFI * fSDCLK) - 20
tREFI = 7.8125us (64ms/8192)
Beispiel: fSDCLK=84MHz -> 7.8125e-6*84e6=656 -> 656-20=636
*/
int refreshrate = (int)(68e6*(64e-3/8192.0))-20;
FMC_SDRAM_CommandTypeDef cmd;
/* Step 1: Clock enable command */
cmd.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE;
cmd.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1; // Bank1 = 0xD0000000
cmd.AutoRefreshNumber = 1;
cmd.ModeRegisterDefinition = 0;
if (HAL_SDRAM_SendCommand(hsdram, &cmd, 0x1000) != HAL_OK) Error_Handler();
HAL_Delay(1);
/* Step 2: Precharge all command */
cmd.CommandMode = FMC_SDRAM_CMD_PALL;
if (HAL_SDRAM_SendCommand(hsdram, &cmd, 0x1000) != HAL_OK) Error_Handler();
/* Step 3: Auto refresh command */
cmd.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE;
cmd.AutoRefreshNumber = 8;
if (HAL_SDRAM_SendCommand(hsdram, &cmd, 0x1000) != HAL_OK) Error_Handler();
/* Step 4: Load Mode Register
Beispiel-Mode: BurstLen=1, BurstType=Seq, CAS=3, Single write burst
*/
uint32_t mode =
0
| (0x0 << 0) /* Burst Length = 1 */
| (0x0 << 3) /* Burst Type = Sequential */
| (0x3 << 4) /* CAS Latency = 3 */
| (0x0 << 7) /* Operating Mode = Standard */
| (0x1 << 9); /* Write Burst Mode = Single */
cmd.CommandMode = FMC_SDRAM_CMD_LOAD_MODE;
cmd.AutoRefreshNumber = 1;
cmd.ModeRegisterDefinition = mode;
if (HAL_SDRAM_SendCommand(hsdram, &cmd, 0x1000) != HAL_OK) Error_Handler();
/* Step 5: Set refresh rate */
// Für SDCLK=84MHz:
if (HAL_SDRAM_ProgramRefreshRate(hsdram, refreshrate) != HAL_OK) Error_Handler();
}
2026-02-06 1:05 AM
Hi,
I do not accept this as a solution.
>>>> But: In a complete Test of all 0x400000 16Bit words I always see 3-6 faults.
If I touch the SDRAM Chip it goes up to hundreds of faulty cells.
The timing or whatever is still messy.
The main things of the STM32F429I-DISC is the SDRAM and the LCD. There is no working example provided by STM that addresses these two key components. This is not great customer service and will exclude the STM32F429 from a product if I will not get it flying within a reasonable timeframe.
Cheers
Detlef
2026-02-09 2:33 PM
Hi,
finally managed to run SDRAM and LCD on STM32F429I-DISC. There was no example for this for Cube IDE. The only working example ADC_DMA was 10y old and still for Attolic Studio, I did not want to work on that platform. I could not migrate the BSP-stuff to CubeIDE. I generated a static library from ADC_DMA and called SDRAM_InitSequence() and LCD_Init() . That finally worked.
I would have wished a working SDRAM and LCD example for CubeIDE and more support on my lonely way through the #define jungle e.g. PIN versus Pin.
Cheers
Detlef