cancel
Showing results for 
Search instead for 
Did you mean: 

SDRAM interfacing issue

DPRAJ.1
Associate II

I am using 12.1" TFT Display of 800x600 resolution and interfacing it with STM32F429BI Micro-controller and IS42S16400J SDRAM .I am getting the flickering issue in my display. When i by pass the SDRAM it working ok , there is no flickering, but on connecting through SDRAM it starts giving flickering issue.

Video of above mentioned problems is attached.

3 REPLIES 3

Unless the video has details about the memory interface, width and speed settings I'm not sure watching it will help me.

Post the details about SDRAM and LTDC settings.

I​s the memory 32-bit wide?

Have you tried reducing the colour depth. How about pixel clock or refresh rate? What are the display specs and parameters?

800x600 is close to bandwidth ceiling​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
DPRAJ.1
Associate II

Below mentioned are the details you said.

refresh count is 1386

void SystemClock_Config(void)

{

 RCC_OscInitTypeDef RCC_OscInitStruct;

 RCC_ClkInitTypeDef RCC_ClkInitStruct;

 RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;

 __PWR_CLK_ENABLE();

 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE;

 RCC_OscInitStruct.HSEState = RCC_HSE_ON;

 RCC_OscInitStruct.LSEState = RCC_LSE_ON;

 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

 RCC_OscInitStruct.PLL.PLLM =4;// 5;

 RCC_OscInitStruct.PLL.PLLN =180;//144; //225;

 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;

 RCC_OscInitStruct.PLL.PLLQ = 4;

 HAL_RCC_OscConfig(&RCC_OscInitStruct);

 HAL_PWREx_ActivateOverDrive();

 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_SYSCLK|RCC_CLOCKTYPE_PCLK1

               |RCC_CLOCKTYPE_PCLK2;

 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;

 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV4;

 HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5);

 PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC|RCC_PERIPHCLK_RTC;

 PeriphClkInitStruct.PLLSAI.PLLSAIN =144;//201;//146; //181;

 PeriphClkInitStruct.PLLSAI.PLLSAIR = 4;//2;

 PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_4;//8;

 PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;

 HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct);

 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

 HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

 /* SysTick_IRQn interrupt configuration */

 HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

}

void MX_LTDC_Init(void)

{

LTDC_LayerCfgTypeDef pLayerCfg;

 hltdc.Instance = LTDC;

 hltdc.Init.HSPolarity =LTDC_HSPOLARITY_AH;// LTDC_HSPOLARITY_AL;

 hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;//LTDC_VSPOLARITY_AL;

 hltdc.Init.DEPolarity =LTDC_DEPOLARITY_AL; //LTDC_DEPOLARITY_AL;

 hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;

 hltdc.Init.HorizontalSync = 40;

 hltdc.Init.VerticalSync = 9;

 hltdc.Init.AccumulatedHBP = 42;

 hltdc.Init.AccumulatedVBP = 11;

 hltdc.Init.AccumulatedActiveW = 1054;

 hltdc.Init.AccumulatedActiveH = 664;

 hltdc.Init.TotalWidth = 1056;

 hltdc.Init.TotalHeigh = 666;

 hltdc.Init.Backcolor.Blue = 0;

 hltdc.Init.Backcolor.Green = 0;

 hltdc.Init.Backcolor.Red = 0;

 HAL_LTDC_Init(&hltdc);

 pLayerCfg.WindowX0 = 0;

 pLayerCfg.WindowX1 = 800;//800;//240;

 pLayerCfg.WindowY0 = 0;

 pLayerCfg.WindowY1 = 600;//320;//160;

 pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;

 pLayerCfg.Alpha = 255;

 pLayerCfg.Alpha0 = 0;

 pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA;

 pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA;

 pLayerCfg.FBStartAdress = SDRAM_DEVICE_ADDR;//(uint32_t)&Color;

 pLayerCfg.ImageWidth = 800;

 pLayerCfg.ImageHeight = 600;

 pLayerCfg.Backcolor.Blue = 0;

 pLayerCfg.Backcolor.Green = 0;

 pLayerCfg.Backcolor.Red = 0;

 HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0);

}

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_BANK2;

 hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8;

 hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12;//FMC_SDRAM_ROW_BITS_NUM_11;

 hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_16;

 hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4;

 hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3;//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_DISABLE;

 hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_1;//FMC_SDRAM_RPIPE_DELAY_0;

 /* SdramTiming */

/* SdramTiming.LoadToActiveDelay = 16;

 SdramTiming.ExitSelfRefreshDelay = 16;

 SdramTiming.SelfRefreshTime = 16;

 SdramTiming.RowCycleDelay = 16;

 SdramTiming.WriteRecoveryTime = 16;

 SdramTiming.RPDelay = 16;

 SdramTiming.RCDDelay = 16;*/

SdramTiming.LoadToActiveDelay  = 2;

 /* TXSR: min=70ns (7x11.11ns) */

 SdramTiming.ExitSelfRefreshDelay = 14;//7;

 /* TRAS: min=42ns (4x11.11ns) max=120k (ns) */

 SdramTiming.SelfRefreshTime   = 14;//4;

 /* TRC: min=70 (7x11.11ns) */

 SdramTiming.RowCycleDelay    = 14;//7;

 /* TWR: min=1+ 7ns (1+1x11.11ns) */

 SdramTiming.WriteRecoveryTime  = 2;

 /* TRP: 20ns => 2x11.11ns*/

 SdramTiming.RPDelay       = 4;//2;

 /* TRCD: 20ns => 2x11.11ns */

 SdramTiming.RCDDelay       = 4;//2;

 HAL_SDRAM_Init(&hsdram1, &SdramTiming);

 BSP_SDRAM_Initialization_sequence(REFRESH_COUNT);

}

void BSP_SDRAM_Initialization_sequence(uint32_t RefreshCount)

{

 __IO uint32_t tmpmrd =0;  

 /* Step 1: Configure a clock configuration enable command */

 Command.CommandMode       = FMC_SDRAM_CMD_CLK_ENABLE;

 Command.CommandTarget      = FMC_SDRAM_CMD_TARGET_BANK2;

 Command.AutoRefreshNumber    = 1;

 Command.ModeRegisterDefinition = 0;

 /* Send the command */

 HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);

 /* Step 2: Insert 100 us minimum delay */ 

 /* Inserted delay is equal to 1 ms due to systick time base unit (ms) */

 HAL_Delay(1);

 /* Step 3: Configure a PALL (precharge all) command */ 

 Command.CommandMode       = FMC_SDRAM_CMD_PALL;

 Command.CommandTarget      = FMC_SDRAM_CMD_TARGET_BANK2;

 Command.AutoRefreshNumber    = 1;

 Command.ModeRegisterDefinition = 0;

//// /* Send the command */

 //HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);  

HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT); 

////  

// /* Step 4: Configure an Auto Refresh command */ 

 Command.CommandMode       = FMC_SDRAM_CMD_AUTOREFRESH_MODE;

 Command.CommandTarget      = FMC_SDRAM_CMD_TARGET_BANK2;

 Command.AutoRefreshNumber    = 4;

 Command.ModeRegisterDefinition = 0;

//// /* Send the command */

 HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);

////  

// /* Step 5: Program the external memory mode register */

 tmpmrd = (uint32_t)SDRAM_MODEREG_BURST_LENGTH_1     |

          SDRAM_MODEREG_BURST_TYPE_SEQUENTIAL  |

          SDRAM_MODEREG_CAS_LATENCY_3      |

          SDRAM_MODEREG_OPERATING_MODE_STANDARD |

           SDRAM_MODEREG_WRITEBURST_MODE_SINGLE;

  

 Command.CommandMode       = FMC_SDRAM_CMD_LOAD_MODE;

 Command.CommandTarget      = FMC_SDRAM_CMD_TARGET_BANK2;

 Command.AutoRefreshNumber    = 1;

 Command.ModeRegisterDefinition = tmpmrd;

//// /* Send the command */

 HAL_SDRAM_SendCommand(&hsdram1, &Command, SDRAM_TIMEOUT);

////  

//// /* Step 6: Set the refresh rate counter */

//// /* Set the device refresh rate */

 HAL_SDRAM_ProgramRefreshRate(&hsdram1, RefreshCount); 

}

DPRAJ.1
Associate II

Hey,

any suggestion or solution for this problem?