cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746IGT / NGx and display with 1024*768

xakkez
Associate II
Posted on November 01, 2016 at 18:34

Hello,

I try launch showing image with 1024*768*24/16 resolution.

But I see bad image and many bugs on screen.

I get timing from here: http://tinyvga.com/vga-timing

I have static image.

I get LTDC outputs, connect this to adapter to VGA. My display detects 1024*768 60Hz and I see pixel's dance.

P.S. I try 640*480.. and it works bad.

#dma2d #stm32f7 #ltdc #vga
8 REPLIES 8
ST Renegade
Senior
Posted on November 01, 2016 at 21:49

Hello ,

it appears your LTDC timings are improperly configured or the issue can be caused by writing into your frame buffer while data being displayed/read by the LTDC peripheral.

What kind of adaptor are you using? A datasheet will help a lot...

Have a nice day,

Renegade
xakkez
Associate II
Posted on November 01, 2016 at 22:13

I have 1 color on all buffer and it's static image. LTDC starts after fill buffer.

Adaptor is simple hand-made DAC: I have 8 parallel resistors for one color, it's 255 steps for one color. 
Posted on November 02, 2016 at 00:14

If you expect any level of technical analysis I'd recommend posting a complete/concise example that demonstrates your configuration and issue.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
ST Renegade
Senior
Posted on November 02, 2016 at 08:29

Morning zuev.dmitrii,

as Clive1 said, the more information you provide, the easier it will be to help you. However, here is an interesting link which can help you from HW point of view:

https://olimex.wordpress.com/2012/06/12/low-cost-lcd-to-vga-adapter/

Regarding SW, make sure the clock prescalers are configured in a proper way so you habe 65 MHz for the LTDC.

Not sure whether you are configuring the LTDC directly into registers or you use the ST HAL library, however make sure the values are set correctly. Some registers require N - 1 value.

Have a nice day,

Renegade

xakkez
Associate II
Posted on November 02, 2016 at 10:30

Init functions:

void SystemClock_Config(void)

{

  RCC_OscInitTypeDef RCC_OscInitStruct;

  RCC_ClkInitTypeDef RCC_ClkInitStruct;

  RCC_PeriphCLKInitTypeDef PeriphClkInitStruct;

  __HAL_RCC_PWR_CLK_ENABLE();

  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;

  RCC_OscInitStruct.HSEState = RCC_HSE_ON;

  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

  RCC_OscInitStruct.PLL.PLLM = 4;

  RCC_OscInitStruct.PLL.PLLN = 200;

  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;

  RCC_OscInitStruct.PLL.PLLQ = 9;

  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

  {

    Error_Handler();

  }

  if (HAL_PWREx_EnableOverDrive() != HAL_OK)

  {

    Error_Handler();

  }

  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|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_DIV2;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_6) != HAL_OK)

  {

    Error_Handler();

  }

  PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC|RCC_PERIPHCLK_USART1

                              |RCC_PERIPHCLK_I2C4|RCC_PERIPHCLK_SDMMC1

                              |RCC_PERIPHCLK_CLK48;

  PeriphClkInitStruct.PLLSAI.PLLSAIN = 195;

  PeriphClkInitStruct.PLLSAI.PLLSAIR = 3;

  PeriphClkInitStruct.PLLSAI.PLLSAIQ = 2;

  PeriphClkInitStruct.PLLSAI.PLLSAIP = RCC_PLLSAIP_DIV2;

  PeriphClkInitStruct.PLLSAIDivQ = 1;

  PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2;

  PeriphClkInitStruct.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;

  PeriphClkInitStruct.I2c4ClockSelection = RCC_I2C4CLKSOURCE_PCLK1;

  PeriphClkInitStruct.Clk48ClockSelection = RCC_CLK48SOURCE_PLL;

  PeriphClkInitStruct.Sdmmc1ClockSelection = RCC_SDMMC1CLKSOURCE_CLK48;

  if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK)

  {

    Error_Handler();

  }

  HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);

  HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);

  /* SysTick_IRQn interrupt configuration */

  HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);

}

static void MX_LTDC_Init(void)

{

  LTDC_LayerCfgTypeDef pLayerCfg;

  hltdc.Instance = LTDC;

  hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AL;

  hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AL;

  hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL;

  hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;

  hltdc.Init.HorizontalSync = 135;

  hltdc.Init.VerticalSync = 5;

  hltdc.Init.AccumulatedHBP = 295;

  hltdc.Init.AccumulatedVBP = 34;

  hltdc.Init.AccumulatedActiveW = 1319;

  hltdc.Init.AccumulatedActiveH = 802;

  hltdc.Init.TotalWidth = 1343;

  hltdc.Init.TotalHeigh = 805;

  hltdc.Init.Backcolor.Blue = 0;

  hltdc.Init.Backcolor.Green = 0;

  hltdc.Init.Backcolor.Red = 0;

  if (HAL_LTDC_Init(&hltdc) != HAL_OK)

  {

    Error_Handler();

  }

  pLayerCfg.WindowX0 = 0;

  pLayerCfg.WindowX1 = 1024;

  pLayerCfg.WindowY0 = 0;

  pLayerCfg.WindowY1 = 768;

  pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;

  pLayerCfg.Alpha = 255;

  pLayerCfg.Alpha0 = 255;

  pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;

  pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;

  pLayerCfg.FBStartAdress = WRITE_READ_ADDR+SDRAM_BANK_ADDR;

  pLayerCfg.ImageWidth = 1024;

  pLayerCfg.ImageHeight = 768;

  pLayerCfg.Backcolor.Blue = 0;

  pLayerCfg.Backcolor.Green = 0;

  pLayerCfg.Backcolor.Red = 0;

  if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK)

  {

    Error_Handler();

  }

}

Init screen:

uint32_t i=0;

for(j=0;j<1024*768;j++){

   *(__IO uint16_t*)(SDRAM_BANK_ADDR+WRITE_READ_ADDR+j*2) = 0xF800; /*RGB565  only RED*/

}

xakkez
Associate II
Posted on November 02, 2016 at 10:34

I have a same adaptor. I use HAL Library with CubeMx. Compile code in TrueStudio.

And I try do it on board: www.waveshare.com/wiki/Core746I

Maybe this board is bad? :)

Posted on November 02, 2016 at 13:03

replace

  pLayerCfg.WindowX0 = 0;

  pLayerCfg.WindowX1 = 1024;

  pLayerCfg.WindowY0 = 0;

  pLayerCfg.WindowY1 = 768;

with

  pLayerCfg.WindowX0 = 0;

  pLayerCfg.WindowX1 = 1023;

  pLayerCfg.WindowY0 = 0;

  pLayerCfg.WindowY1 = 767;

One Pixel too much for x and y. When you start at 0 you should stop at x/y Resolution -1.

xakkez
Associate II
Posted on November 03, 2016 at 10:57

I do it!

But I don't understand why it works:)

The first:

hltdc.Init.HorizontalSync = 135+1; //This fixes first pixel's danse

  hltdc.Init.VerticalSync = 5;

  hltdc.Init.AccumulatedHBP = 295-80;//about this I write later... :)

  hltdc.Init.AccumulatedVBP = 34;

  hltdc.Init.AccumulatedActiveW = 1319+1;

Second:

 pLayerCfg.WindowX0 = 40;

  pLayerCfg.WindowX1 = 1024-1+40;

  pLayerCfg.WindowY0 = 0;

  pLayerCfg.WindowY1 = 768-1;

I don't know why I try wrote ''40'' but now I have stable picture!