AnsweredAssumed Answered

STM32F7 and SDRAM initialization problem

Question asked by Eetu Piukkula on Feb 19, 2018
Latest reply on Feb 23, 2018 by Eetu Piukkula

Hi,

I am university student from Finland and I am doing school project with STM32F769IIT6 MCU and Alliance AS4C1M16S-C&I SDRAM. End goal is to use SDRAM as framebuffer for MIPI-DSI interface. We have custom PCB and previous and current revisions of PCB have proven that MCU it self is working and power etc. lines are OK. Serial and GPIO configurations do work. Problem that I am facing is when initializing SDRAM and FMC. I have ST-LinkV2 so I can see whats happening in registers. Problem:

 

### CODE SNIPPLET ###

//MAIN

int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_FMC_Init();

/* USER CODE BEGIN 2 */


SDRAM_Init(&hsdram1, &SDRAM_DebugFlag, &SDRAM_InitFlag);
MainDebugFlag = 4;

 

MainDebugFlag = 5;
while (1){
MainDebugFlag = 6;
HAL_Delay(100);

}

 

// CUBEMX

static 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_8;
hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12;
hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_8;
hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_2;
hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_2;
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 = 7;
SdramTiming.SelfRefreshTime = 4;
SdramTiming.RowCycleDelay = 6;
SdramTiming.WriteRecoveryTime = 2;
SdramTiming.RPDelay = 2;
SdramTiming.RCDDelay = 2;

if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}

}

 

 

void SDRAM_Init(SDRAM_HandleTypeDef *hsdram1, uint8_t *SDRAM_DebugFlag, uint8_t *SDRAM_InitFlag){

FMC_SDRAM_CommandTypeDef cmd;

uint32_t SDRAMTimeout = 50;


//Step 1 - clock
cmd.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
cmd.CommandMode = FMC_SDRAM_CMD_CLK_ENABLE;
cmd.AutoRefreshNumber = 1;
HAL_SDRAM_SendCommand(&hsdram1, &cmd, SDRAMTimeout);

*SDRAM_DebugFlag = 1;

//Step 2 - delay
HAL_Delay(SDRAMTimeout);

*SDRAM_DebugFlag = 2;

//Step 3 - PALL
cmd.CommandMode = FMC_SDRAM_CMD_PALL;
cmd.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
HAL_SDRAM_SendCommand(&hsdram1, &cmd, SDRAMTimeout);

*SDRAM_DebugFlag = 3;

//Step 4 - Auto-Refresh
cmd.CommandMode = FMC_SDRAM_CMD_AUTOREFRESH_MODE;
cmd.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
cmd.AutoRefreshNumber = 2;
HAL_SDRAM_SendCommand(&hsdram1, &cmd, SDRAMTimeout);

*SDRAM_DebugFlag = 4;

//Step 5 - External memory mode register
cmd.CommandMode = FMC_SDRAM_CMD_LOAD_MODE;
cmd.CommandTarget = FMC_SDRAM_CMD_TARGET_BANK1;
cmd.ModeRegisterDefinition = 0x0220;
HAL_SDRAM_SendCommand(&hsdram1, &cmd, SDRAMTimeout);

*SDRAM_DebugFlag = 5;

// Step 6 - refresh counter //
// 64ms for 4092 = 15.625us //
// 15.625us * 10MHz - 20 = 136.25 = 0x88 //
HAL_SDRAM_ProgramRefreshRate(&hsdram1, 0x88);

*SDRAM_DebugFlag = 6;
*SDRAM_InitFlag = 1;
}

 

So, first is main where CubeMX's configs are run first and after that SDRAM_Init function. There is also couple of debug flags there. I am not able to get anything reacting with current code. With ST-Links I can see that SdramTiming values do change in hsdram1 expression, but when I examine SDRAM1 control and timing registers there is nothing (all zeroes). Seems like that the whole pheriable is not responding (incorrect clock config? Clock config is made by CubeMX). What am I missing?

 

As an attachment there are couple of screenshots from debugger, from variables that do change and registers that stay 0

 

Sorry for broken English

Outcomes