This section describes the steps needed to configure the LTDC clock and timings respecting the display specifications. It also provides a configuration example for the ROCKTECH (RK043FN48H) display embedded on the STM32F746G-DISCO board.
System clock configuration
It is recommended to use the highest system clock to get the best graphic performances. This recommendation applies also for the external memory framebuffer. So, if an external memory is used for the framebuffer, the highest allowed clock speed must be used to get the best memory bandwidth.
For instance, for the STM32F4x9, the maximum system speed is 180 MHz. So, if an external SDRAM is connected to the FMC, the maximum SDRAM clock is 90 MHz (HCLK/2).
For the STM32F7, the maximum system speed is 216 MHz but with this speed and HCLK/2 prescaler the SDRAM speed exceeds the maximum allowed speed (see product datasheet for more details). So, to get the maximum SDRAM, it is recommended to configure HCLK to 200 MHz, then the SDRAM speed is set to 100 MHz.
The clock configuration providing the highest performances is:
- STM32F4x9:HCLK @ 180 MHz and SDRAM @ 90 MHz
- STM32F7:HCLK @ 200 MHz and SDRAM @ 100 MHz
An example of LTDC configuration using STM32CubeMX is described in LTDC peripheral configuration.
Pixel clock and timings configuration
At this stage of the graphical application development, the user must have already checked and confirmed that the desired display size and color depth are compatible with the hardware configuration. Therefore, the pixel clock to be configured must be already known, either extracted from the display datasheet or calculated (see Checking display compatibility considering the memory bandwidth requirements).
Example: LTDC timings configuration for ROCKTECH RK043FN48H display embedded on the STM32F746G-DISCO board. At first, the user must extract the timing parameters from the display datasheet (see Table 22 LCD-TFT timings extracted from ROCKTECH RK043FN48H datasheet). It is recommended to use typical display timings.
Table 22. LCD-TFT timings extracted from ROCKTECH RK043FN48H datasheet The cells in bold highlight the values used in the example presented below.| Item | Symbol | Min. | Typ. | Max. | Unit |
|---|
| DCLK frequency | Fclk | 5 | 9 | 12 | MHz |
| DCLK period | Tclk | 83 | 110 | 200 | ns |
| Hsync | Period time | Th | 490 | 531 | 605 | DCLK |
| Display period | Thdisp | - | 480 | - | DCLK |
| Back porch | Thbp | 8 | 43 | - | DCLK |
| Front porch | Thfp | 2 | 8 | - | DCLK |
| Pulse width | Thw | 1 | - | - | DCLK |
| Vsync | Period time | Tv | 275 | 288 | 335 | H |
| Display period | Tvdisp | - | 272 | - | H |
| Back porch | Tvbp | 2 | 12 | - | H |
| Front porch | Tvfp | 1 | 4 | - | H |
| Pulse width | Tvw | 1 | 10 | - | H |
Based on the above table, the extracted timing parameters are:
- Display period (active width) = 480 pixels
- Back porch HBP = 43 pixels
- Front porch HFP = 8 pixels
- Pulse width HSYNC = 1 pixel (minimum value)
- Display period (active height) = 272 lines
- Vertical back porch VBP = 12 lines
- Front porch VFP = 4 lines
- Pulse width VSYNC = 10 lines
Program timing parameters: once timing parameters are extracted, they are used to program the LTDC timing registers, Table 23 Programming LTDC timing registers summarizes all the parameters to be programmed.
Timing parameters configuration with STM32CubeMX: it is very easy to program the timing parameters using STM32CubeMX. The user must simply fill the extracted parameters in the LTDC configuration window (see section LTDC peripheral configuration).
Table 23. Programming LTDC timing registers| Register | - | Value to be programmed |
|---|
| LTDC_SSCR | HSW[11:0] | HSYNC Width - 1 | 0 |
| VSH[11:0] | VSYNC Height - 1 | 9 |
| LTDC_BPCR | AHBP[11:0] | HSYNC Width + HBP - 1 | 43 |
| AVBP[10:0] | VSYNC Height + VBP - 1 | 21 |
| LTDC_AWCR | AAW[11:0] | HSYNC Width + HBP + Active Width - 1 | 523 |
| AAH[10:0] | VSYNC Height + BVBP + Active Height - 1 | 293 |
| LTDC_TWCR | TOTALW[11:0] | HSYNC Width + HBP + Active Width + HFP - 1 | 531 |
| TOTALH[10:0] | VSYNC Height+ BVBP + Active Height + VFP - 1 | 297 |
Pixel clock configuration with STM32CubeMX: the pixel clock is calculated with a 60 Hz refresh rate as shown below:
LCD_CLK = TOTALW x TOTALH x refresh rate
Based on Table 23 Programming LTDC timing registers, TOTALW= 531 and TOTALH = 297.
And for this example:
LCD_CLK = 531 x 297 x 60 = 9.5 MHz
Refer to the LTDC pixel clock configuration STM32CubeMX example in LTDC peripheral configuration.
LTDC control signals polarity configuration
The LTDC control signals (HSYNC, VSYNC, DE, and LCD_CLK) polarities must be configured respecting the display specifications.
Note: Only the DE control signal must be inverted versus the DE polarity indicated in the display datasheet. The other control signals must be configured exactly like the display datasheet.