cancel
Showing results for 
Search instead for 
Did you mean: 

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

JNguyen
Senior

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?

14 REPLIES 14
JNguyen
Senior

5" LCD spec.

MM..1
Chief II

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
Senior

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.

JNguyen
Senior

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

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
Senior

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.

JNguyen
Senior

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

pLayerCfg.FBStartAdress = (uint32_t)Mushroom380x600;
without call to init do nothing.
But primary change too
pLayerCfg.Alpha = 255;
JNguyen
Senior

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.