Skip to main content
JNguyen
Senior
November 8, 2021
Question

How to get 5" TFT LCD working with STM32H7A3 using LTDC and CubeIDE

  • November 8, 2021
  • 14 replies
  • 8315 views

I have STM32H7A3ZIQ Nucleo board and 5" Startek LCD KD050FWFPA011. I'd like to use CubeIDE to create code to copy an image from H7A's flash memory to the LCD using LTDC. I did get STM32H7A3ZIQ Nucleo to work with a 2" LCD using 4-wire SPI interface. The problem I have with 5" LCD is the LTDC interface. Attached is IOC file, CubeIDE code, init code from Startek, scope captures, etc.... Please help.

I got black screen. Backlight is on. IDE reports the image (Mushroom480x800) is defined but not used. Scope captures show 0x00 on pin LTDC_R4. LTDC_CLK is 24MHz, correct as designed. What do I miss?

This topic has been closed for replies.

14 replies

JNguyen
JNguyenAuthor
Senior
November 8, 2021
MM..1
Super User
November 9, 2021

For use LCD you need some step and condition meet. Show image is last step...

Try explain what is problem , is your lcd init accepted, can command to lcd show white lcd usw...

From Nucleo you need for RGB24 connect to LCD around 30 high speed signals ...

JNguyen
JNguyenAuthor
Senior
November 9, 2021

There are 3 areas problems could exist in: 1) LCD initializing, 2)wiring between nucleo board and LCD, and 3)configuring/using LTDC. I have double checked the 1st two areas and haven't found any problem. I'm still working with LCD manuf in those areas. For now, the area I need help the most from ST is the 3rd one (LTDC). So I would much appreciate if anyone could review the IOC and code to see if I miss anything (most likely), and provide detail instructions. I have read documents/sample code about LTDC I could find, but still couldn't get it to work.

Connection between nucleo and LCD is per the IOC file and attached schematics.

MM..1
Super User
November 9, 2021

All except layer config seems good. LTDC layer is window onj display managed with memory framebuffer.

You in code need reserve memory and set it in Layer 0 - Color Frame Buffer Start Adress

When your config for layer is 565 then for example image 100x100 need 20000bytes .

I recomend start with internal memory and set 0 to 99 x and y ... Finaly this window is full LCD, but first step is simpler with small window.

Good is read LTDC appnote LCD-TFT display controller (LTDC) on STM32 MCUs - Application note

JNguyen
JNguyenAuthor
Senior
November 9, 2021

I'm able to send ALL_PIXELS_ON, ALL_PIXELS_OFF cmds to LCD repeatedly. LCD turns white and black repeatedly.

JNguyen
JNguyenAuthor
Senior
November 9, 2021

I already have memory reserve for Layer 0 - Color Frame Buffer Start Adress in MX_LTDC_Init() below:

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

 hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;

 hltdc.Init.HorizontalSync = 3;

 hltdc.Init.VerticalSync = 3;

 hltdc.Init.AccumulatedHBP = 33;

 hltdc.Init.AccumulatedVBP = 33;

 hltdc.Init.AccumulatedActiveW = 513;

 hltdc.Init.AccumulatedActiveH = 833;

 hltdc.Init.TotalWidth = 531;

 hltdc.Init.TotalHeigh = 853;

 hltdc.Init.Backcolor.Blue = 0;

 hltdc.Init.Backcolor.Green = 127;

 hltdc.Init.Backcolor.Red = 0;

 if (HAL_LTDC_Init(&hltdc) != HAL_OK)

 {

   Error_Handler();

 }

 pLayerCfg.WindowX0 = 0;

 pLayerCfg.WindowX1 = 480;

 pLayerCfg.WindowY0 = 0;

 pLayerCfg.WindowY1 = 800;

 pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;

 pLayerCfg.Alpha = 0;

 pLayerCfg.Alpha0 = 0;

 pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;

 pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;

 pLayerCfg.FBStartAdress = 0;

 pLayerCfg.ImageWidth = 380;

 pLayerCfg.ImageHeight = 600;

 pLayerCfg.Backcolor.Blue = 0;

 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 */

 pLayerCfg.FBStartAdress = (uint32_t)Mushroom380x600;

 /* USER CODE END LTDC_Init 2 */

}

I also tried a small image (Mushroom380x600). The result is the same.

MM..1
Super User
November 10, 2021
pLayerCfg.FBStartAdress = (uint32_t)Mushroom380x600;
without call to init do nothing.
But primary change too
pLayerCfg.Alpha = 255;
JNguyen
JNguyenAuthor
Senior
November 9, 2021

From scope captures, I don't see data on RGB pins during active DE.

JNguyen
JNguyenAuthor
Senior
November 10, 2021

I tried below codes. It didn't help.

 /* USER CODE BEGIN LTDC_Init 2 */

 pLayerCfg.FBStartAdress = (uint32_t)Mushroom380x600;

 if (HAL_LTDC_Init(&hltdc) != HAL_OK)  Error_Handler();

 /* USER CODE END LTDC_Init 2 */

--------and -------

 /* USER CODE BEGIN LTDC_Init 2 */

 pLayerCfg.FBStartAdress = (uint32_t)Mushroom380x600;

if (HAL_LTDC_Init(&hltdc) != HAL_OK)  Error_Handler();

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

 /* USER CODE END LTDC_Init 2 */

I also tried HAL_LTDC_DeInit(&hltdc) before HAL_LTDC_Init(&hltdc). It didn't help.

JNguyen
JNguyenAuthor
Senior
November 10, 2021

LTDC_IRQHandler(void) is never been called. I've been looking for reason why IRQ is not generated.

From scope captures, VSYNC and HSYNC are generated continuously. RGB data lines are 0x0.

MM..1
Super User
November 10, 2021

Try edit generated part before you understand howto...

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_AH;
 hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC;
 hltdc.Init.HorizontalSync = 3;
 hltdc.Init.VerticalSync = 3;
 hltdc.Init.AccumulatedHBP = 33;
 hltdc.Init.AccumulatedVBP = 33;
 hltdc.Init.AccumulatedActiveW = 513;
 hltdc.Init.AccumulatedActiveH = 833;
 hltdc.Init.TotalWidth = 531;
 hltdc.Init.TotalHeigh = 853;
 hltdc.Init.Backcolor.Blue = 0;
 hltdc.Init.Backcolor.Green = 127;
 hltdc.Init.Backcolor.Red = 0;
 if (HAL_LTDC_Init(&hltdc) != HAL_OK)
 {
 Error_Handler();
 }
 pLayerCfg.WindowX0 = 0;
 pLayerCfg.WindowX1 = 480;
 pLayerCfg.WindowY0 = 0;
 pLayerCfg.WindowY1 = 800;
 pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565;
 pLayerCfg.Alpha = 255; //!!!
 pLayerCfg.Alpha0 = 0;
 pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_CA;
 pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_CA;
 //pLayerCfg.FBStartAdress = 0;
 pLayerCfg.FBStartAdress = (uint32_t)Mushroom380x600;
 pLayerCfg.ImageWidth = 480;
 pLayerCfg.ImageHeight = 800;
 pLayerCfg.Backcolor.Blue = 0;
 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 */
}

JNguyen
JNguyenAuthor
Senior
November 10, 2021

I got the same result. LTDC IRQ is not generated. It's enable in CubeMX. Do you have any idea?

I issue ALL_PIXELS_ON/OFF commands, and LCD goes white/black. So LCD is init'ed correctly.

Scope capture shows CLK, HSYNC, DE, non-zero RGB.