cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H750B-DK LTC example

MLang.7
Associate III

After tinkering with some of those cheap SPI displays, I would like to use the LTDC controller of the STM32H7 MCU. From my current research, I understand that the LCD controller controls the attached display, allowing me to push data stored in a frame buffer, much like I already did with my SPI displays.

Therefore, I looked at one of the demo projects provided by ST displaying an image on the integrated LCD display. Since the demo project didn't run because of a debugger error, I would like to come up with my own example. I therefore intend:

- Let the LCD display custom data.

At this point, I would consider the noise pattern from an uninitialized RAM section a success. I set up a new project and configured clocks and the LTDC according to the demo project from ST:

 

 

static void MX_LTDC_Init(void)
{

  /* USER CODE BEGIN LTDC_Init 0 */

  /* USER CODE END LTDC_Init 0 */

  LTDC_LayerCfgTypeDef pLayerCfg = {0};

  /* USER CODE BEGIN LTDC_Init 1 */

  /* USER CODE END LTDC_Init 1 */
  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 = 40;
  hltdc.Init.VerticalSync = 9;
  hltdc.Init.AccumulatedHBP = 53;
  hltdc.Init.AccumulatedVBP = 11;
  hltdc.Init.AccumulatedActiveW = 533;
  hltdc.Init.AccumulatedActiveH = 283;
  hltdc.Init.TotalWidth = 565;
  hltdc.Init.TotalHeigh = 285;
  hltdc.Init.Backcolor.Blue = 0;
  hltdc.Init.Backcolor.Green = 0;
  hltdc.Init.Backcolor.Red = 0xFF;
  if (HAL_LTDC_Init(&hltdc) != HAL_OK)
  {
    Error_Handler();
  }
  pLayerCfg.WindowX0 = 0;
  pLayerCfg.WindowX1 = 480;
  pLayerCfg.WindowY0 = 0;
  pLayerCfg.WindowY1 = 272;
  pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_ARGB8888;
  pLayerCfg.Alpha = 255;
  pLayerCfg.Alpha0 = 255;
  pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
  pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
  pLayerCfg.FBStartAdress = 0;
  pLayerCfg.ImageWidth = 480;
  pLayerCfg.ImageHeight = 272;
  pLayerCfg.Backcolor.Blue = 255;
  pLayerCfg.Backcolor.Green = 0;
  pLayerCfg.Backcolor.Red = 0;
  if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN LTDC_Init 2 */

  /* USER CODE END LTDC_Init 2 */

}

 

 

Then allocated the frame buffer. Since the display used features a resolution of 480 x 272 pixels and 3 bytes of color per pixel, I allocated 391680 bytes in the RAM_D1 region. Then I assigned the frame buffer in main.c:

 

 

/* USER CODE BEGIN PV */

__attribute__((section(".FrameBuffer"))) uint8_t framebuffer[FB_BUFFER_NBR][FRAMEBUFFER_SIZE];

/* USER CODE END PV */

 

 

 

 

 

 MX_GPIO_Init();
  MX_FMC_Init();
  MX_LTDC_Init();
  /* USER CODE BEGIN 2 */
  //memset(frame_buffer, 0x1F, 0xFF);

  if (HAL_OK != HAL_LTDC_SetAddress(&hltdc, (uint32_t)&framebuffer, 0))
  {
	  Error_Handler();
  }

  if (HAL_OK != HAL_LTDC_Reload(&hltdc, LTDC_RELOAD_VERTICAL_BLANKING))
  {
	  Error_Handler();
  }

while (1)
  {
HAL_GPIO_TogglePin(LD1_GPIO_Port,LD1_Pin);
	  HAL_Delay(250);
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }

 

 


The project was compiled and loaded to the demo board. While to code seems to work, as the Error_Handler() isn't called, the display still shows a blank page. So I would like to know, how the HAL LTDC can be used and which prerequisites need to be fulfilled, in order to run this simple example.

 

1 REPLY 1
STTwo-32
ST Employee

Hello @MLang.7 

I suggest you take a look at the AN4861 that may help you understanding how LTDC works. Also, this Application should guide you on how to do your configurations (make sur to read carefully the README file of the application to understand how to use it).

Best Regards.

STTwo-32 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.