I am using stm32h743ii microcontroller and interfaced with a external sdram of 512mb ( micron - MT48LC64M8A2P) .
I have created the initial code using cubemx and performing basic read write test code by taking a reference of example code provided with stm32h7 firmware. Initialization code :
void MX_FMC_Init(void)
{
FMC_SDRAM_TimingTypeDef SdramTiming;
/** Perform the SDRAM1 memory initialization sequence
*/
hsdram1.Instance = FMC_SDRAM_DEVICE;
/* hsdram1.Init */
hsdram1.Init.SDBank = FMC_SDRAM_BANK1;
hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_11;
hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_13;
hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_8;
hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;
hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_1;
hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE;
hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2;
hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE;
hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0;
/* SdramTiming */
SdramTiming.LoadToActiveDelay = 2;
SdramTiming.ExitSelfRefreshDelay =8;
SdramTiming.SelfRefreshTime = 5;
SdramTiming.RowCycleDelay = 7;
SdramTiming.WriteRecoveryTime =3;
SdramTiming.RPDelay = 2;
SdramTiming.RCDDelay = 2;
if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
All the timing parameters is configured by taking reference from the datasheet.
Issue : I am testing the read write by writing 1 to 4096 index to bank 1 and then read back from the same memory. When I test this I am getting the written data is multiplied with a factor of 256. Eg, If I write 1 to any memory address then I read back it as 256.