1. Enable LCD Backlight
Set the gpio corresponding to the LCD backlight to prohibit pulling (gpxup corresponding bit write 1), select the output type (gpxcon corresponding bit write 01 ), output is high (gpxdat corresponding bit write 1 ).
2. Enable LCD Power Supply
Gpg4 can be selected as LCD _pwren (gpgcon: 9-8 write 11). At this time, the LCD power can be switched on/off through lcdcon5: 3.
You can also customize other gpio as the LCD power switch. You only need to set this gpio to prohibit pulling (gpxup corresponding bit write 1) and select the output type (gpxcon corresponding bit write 01 ), the output is a high level (gpxdat corresponding bit write 1) to turn on the LCD power.
3. Set other signal lines
Other signal lines include VD0-VD23, vframe, vline, vclk, etc., respectively in gpccon, gpdcon select the corresponding function.
4. Set the LCD frequency (vclk)
The Datasheet of the LCD usually shows a recommendation frequency. For example, if the recommended frequency of the screen I use is 6.4 MB, I need to select a suitable clkval through some calculations to generate this frequency:
For tft LCD, the formula for calculating the vclk provided by S3C2440 is:
Vclk = hclk/(clkval + 1) * 2)
We can conclude that:
Clkval = hclk/(vclk * 2)-1
My hclk is 100 MHz (CPU runs at 400 MHz, clkdiv_val is set to 5, fclk: hclk: pclk =), and vclk uses the 6.4 m recommended on the screen:
Clkval = 100000000/(6400000*2)-1 = 6.8
Select the nearest integer 7 and write it into lcdcon1: 17-8.
(Vclk is actually calculated based on the number of frames per second * Number of frames * row pixels. The number of frames and row pixels must contain the number of spaces and the number of the same step)
5. Set Other Related Parameters
LCD parameters mainly include the following:
Lineval: LCD horizontal pixel-1, such as 320-1 = 319
Hozval: LCD vertical pixel-1, such as 240-1 = 239
Hfpd: Number of vclk clock before the start of the line (datasheet on the LCD screen is generally recommended)
Hbpd: Number of vclk clock after the end of the row (datasheet on the LCD screen generally has a recommended value)
Hspw: Number of invalid vclk clock for Horizontal synchronization between rows (datasheet on the LCD screen is generally recommended)
Vfpd: Number of blank lines before the start of frame data (datasheet on the LCD screen is generally recommended)
Vbpd: Number of blank lines after the frame data ends (datasheet on the LCD screen generally has a recommended value)
Vspw: Invalid Number of lines for Vertical synchronization between frames (datasheet on the LCD screen is generally recommended)
(Related registers: lcdcon2, lcdcon3, and lcdcon4)
6. Set the video buffer address
2440 supports Virtual screens and enables rapid screen movement by changing LCD registers
Pagewidth: the number of bytes of a row on the virtual screen. If you do not use the virtual screen, set it to the number of bytes of the row on the actual screen. For example, if the 16-Bit Width is 320 pixels, set it to 320*2.
Offsize: the number of bytes at the left offset of the virtual screen. If the virtual screen is not used, set it to 0.
Lcdbank: Video Frame Buffer Memory Address 30-22 Bits
Lcdbaseu: the starting address of the video frame buffer, Which is 21-1.
Lcdbasel: the end address of the video frame buffer, Which is 21-1.
(Related registers: lcdsaddr1, lcdsaddr2, and lcdsaddr3)
7. Determine the polarity of the signal
The LCD controller of 2440 allows you to set the polarity of signals such as vclk, vline, and vframe (the rising edge is valid or the falling edge is valid), which must be determined one by one against the datasheet of the LCD.
(Related registers lcdcon5)
8. You cannot use the lpc3600/lcc3600 mode!
If you do not use Samsung lpc3600/lcc3600 LCD, you must disable the lpc3600/lcc3600 mode (write 0 to tconsel )!
9. Enable video output
ENVID is set to 1 (lcdcon1: 0 write 1)