LTDC driving diagram of stm32f429

Source: Internet
Author: User
Tags transparent color

This article is based on St official demo board stm32f429 Discovery Hardware platform, in order to see the figure of the form of speaking to you to explain the main parameters of LTDC configuration. The code section mentioned in this article is excerpted from my other article "stm32f429 LTDC code template", LCD hardware for 240x320, driver IC for ili9341. The purpose of this article is to let you through a few pictures can master the stm32f429 LTDC controller configuration Essentials, and from the dry text free out, convenient memory. Of course, this article only explains the Ltdc some common settings, about more details of the operation or to refer to St's official datasheet.


First, about the LTDC peripheral clock configuration, only need to remember the following picture is possible (image from the stm32cubemx RCC clock tree):


The corresponding code for this diagram is as follows:

  /* Configure Pllsai prescalers for LCD */  * Pllsai_vco Input = hse_value/pll_m = 1 Mhz */  * Pllsai_vco Output = Pllsai_vco Input * pllsai_n = 192 MHz */  * PLLLCDCLK = Pllsai_vco Output/pllsai_r = 192/3 = */  */* LTDC CLO CK frequency = PLLLCDCLK/RCC_PLLSAIDIVR = 64/8 = 8 Mhz *  /Rcc_pllsaiconfig (192, 7, 3);  Rcc_ltdcclkdivconfig (RCC_PLLSAIDIVR_DIV8);    /* Enable Pllsai Clock *  /Rcc_pllsaicmd (enable);  /* Wait for PLLSAI activation *  /while (Rcc_getflagstatus (rcc_flag_pllsairdy) = = RESET)  {  }



Second, about the LCD signal timing configuration parameters, only need to remember the following this picture can be:


Note: This section needs to be strictly configured according to the LCD datasheet requirements.

The corresponding code for the change map is as follows:

  /* Initialize The horizontal synchronization polarity as active low*/ltdc_initstruct.ltdc_hspolarity = ltdc_hspolarity       _al; /* Initialize The vertical synchronization polarity as active low */ltdc_initstruct.ltdc_vspolarity = Ltdc_vspolarity_       AL;       /* Initialize The data enable polarity as active low */ltdc_initstruct.ltdc_depolarity = Ltdc_depolarity_al;    /* Initialize the pixel clock polarity as input pixel clock */ltdc_initstruct.ltdc_pcpolarity = LTDC_PCPOLARITY_IPC;  /* Timing Configuration */* Configure Horizontal synchronization Width */Ltdc_initstruct.ltdc_horizontalsync =  9;  /* Configure Vertical Synchronization Height */ltdc_initstruct.ltdc_verticalsync = 1;   /* Configure Accumulated horizontal back porch */ltdc_initstruct.ltdc_accumulatedhbp = 29;    /* Configure Accumulated vertical back porch */ltdc_initstruct.ltdc_accumulatedvbp = 3;  /* Configure Accumulated active width */ltdc_initstruct.ltdc_accumulatedactivew = 269;/* Configure Accumulated active Height */Ltdc_initstruct.ltdc_accumulatedactiveh = 323;   /* Configure Total width */ltdc_initstruct.ltdc_totalwidth = 279; /* Configure Total Height */ltdc_initstruct.ltdc_totalheigh = 327;

Third, the LTDC layer--layer

The concept of a layer has the following points:

1. stm32f429 a total of 3 layers, respectively, background, Layer1, Layer2, the LCD display at any time the image is stacked by the layer of the final result;

2. Background layer is valid at any time, and Layer1, Layer2 can be enabled or forbidden by software configuration;

3. The spatial order of the 3 layers, from bottom to top, is background, Layer1, Layer2, so the stacking order is as follows:


Each Layer Support window operation, the so-called window, means that the image of the layer is valid only within the window area, and the window area is filled with the defaultcolor of that layer. Such as:



For the configuration of the Layer window display location and size, remember this picture:


The corresponding code for this diagram is as follows:

  /* Windowing Configuration *   ///* In the "the" and "all" active display area are used to display a picture then:  Horiz Ontal start = Horizontal synchronization + Horizontal back porch = Horizontal   stop = horizontal start + window Widt  H-1 = + 240-1  Vertical start   = Vertical synchronization + Vertical back Porch     = 4  Vertical Stop   = Vertical start + window height-1  = 4 + 320-1      */   Ltdc_layer_initstruct.ltdc_horizontalstart =;  Ltdc_layer_initstruct.ltdc_horizontalstop = (+ 30-1);   Ltdc_layer_initstruct.ltdc_verticalstart = 4;  


Each layer is associated with a display buffer framebuffer, since background can only be populated with monochrome, so it has no framebuffer. There are several parameters about Framebuffer: Pixel Format, buffer Address, line Length, number of lines, buffer Pitch, these parameters are for the Layer window, They have the following meanings:

Pixel Format: Not much to say, RGB565, ARGB8888, ARGB1555 and so on;

Buffer Address: Displays the starting address of the buffer;

The line Length:window corresponds to a buffer width of +3, in bytes;

Number of Lines:window the corresponding buffer height, in bytes;

Buffer Pitch: The number of bytes passed from the beginning of this line to the beginning of the next line, which is plainly the increment of the row pointer of the newline (also understood as the width of the entire image, in bytes);


Suppose Layer1 's framebuffer such as (RGB565):


Set window to display a pink portion of the image:


Combined with the position of the window previously set, the final display of the image (regardless of Layer2 and transparent color):


From this you can see:

Start Address, Buffer pitch determines the starting position of each row in the video memory of window;

Line Length, line number determines the size of window in memory.

The corresponding code for this section is as follows:

  /* Input Address Configuration *      /ltdc_layer_initstruct.ltdc_cfbstartadress = (u32) FrameBuffer;    /* The length of one line of pixels in bytes + 3 then: line  lenth = Active High width x number of bytes per pixel + 3   Active High Width         =   bytes per pixel = 2    (pixel_format:rgb565)   */  Ltdc_layer_init Struct.ltdc_cfblinelength = ((2) + 3);    /*  The pitch is the increment from the start of a line of pixels   to the start of the next line in bytes, then :  Pitch = Active High width x number of bytes per pixel       *  /Ltdc_layer_initstruct.ltdc_cfbpitch = (240 * 2); /* Configure the number of      lines *  / Ltdc_layer_initstruct.ltdc_cfblinenumber = 320;


It should be noted that in order to ensure the correct display of the image, it is important to verify that the image in the video memory is the same size as the window display, that is, line Length, line number should be consistent with (Hstop-hstart), (Vstop-vstart), Otherwise the display will not be correct.

Finally do not forget to set up all layer registers, the light call Ltdc_layercmd () is not enough, you also need to call the Ltdc_reloadconfig (enable) function to make all layer settings take effect.

LTDC driving diagram of stm32f429

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.