S3C2440 control TFT LCD

Source: Internet
Author: User

The time sequence of tft LCD is complex. Therefore, the S3C2440 involves many tft LCD registers. You just need to carefully compare the LCD manual to set the corresponding 2440 register. Tft LCD is not difficult, but an error in a small place may lead to abnormal display, and it is very difficult to find the error.

 

The compilation involves the following:

1. Time Series and display mode configuration lcdcon1 ~ 5.

2. display the cache address and configure lcdsaddr1 ~ 3.

3. If it is a Samsung LCD, you can use the lcc3600 or lpc3600 controller, then you can use tconsel to enable them. If it is not a Samsung LCD, set tconsel = 0.

4. If the color display is used, I think there are three painting modes (if there are any mistakes, please point them out ):

1) the color palette is not used, and the color information of each pixel is directly stored in the display cache ~ The 23 pin is directly sent to the LCD, because this method can display up to 24-bit images.

2) to use a temporary color palette, you only need to set tpal to open the temporary color palette and assign the color value to tpal, so that the entire LCD screen will be filled with this color. Because tpal stores 24-bit color values, it can only display up to 24-bit images.

3) use the color palette, address 0x4d0004000 ~ 0x4d0007fc each unit in the 256 address is 16 bits and can be used to store the color information to be used. Using the color palette, it seems that some storage units can be omitted, it is unclear how to use the color palette...

 

The following is a program using a 24-bit color palette:

 

# Include "tft_lcd35_lhg.h"
# Include "2440addr. H"
# Include "UART. H"

# Define u32 unsigned int

# Define LCD _width 320
# Define LCD _high 240

Volatile u32 LCD _buffer [LCD _high] [LCD _width]; // display content

// Lcdcon1
# Define s3c2440_lcdconw.linecnt_init (0 <18)
# Define s3c2440_lcdcon1_clkval_init (7 <8)/* TFT-LCD: hclk = 100 MHz, vclk = hclk/[(clkval + 1) * 2] 6.25 MHz */
# Define s3c2440_lcdconw.mmode_init (0 <7)
# Define s3c2440_lcdconw.pnrmode_init (3 <5)/* tft LCD Panel */
# Define s3c2440_lcdconw.bppmode_init (0x0d <1)/* 24 BPP for TFT */
# Define s3c2440_lcdcon1_envid_init (0)/* enable the video output and LCD control signal */

# Define s3c2440_lcdconw.init () (rlcdcon1 = s3c2440_lcdconw.linecnt_init |/
S3c2440_lcdcon1_clkval_init |/
S3c2440_lcdconw.mmode_init |/
S3c2440_lcdconw.pnrmode_init |/
S3c2440_lcdconw.bppmode_init |/
S3c2440_lcdcon1_envid_init)

// Lcdcon2
# Define s3c2440_lcdcon2_vbpd_init (15-1) <24)
# Define s3c2440_lcdcon2_lineval_init (240-1) <14)
# Define s3c2440_lcdcon2_vfpd_init (12-1) <6)
# Define s3c2440_lcdcon2_vspw_init (3-1)
# Define s3c2440_lcdcon2_init () (rlcdcon2 = s3c2440_lcdcon2_vbpd_init |/
S3c2440_lcdcon2_lineval_init |/
S3c2440_lcdcon2_vfpd_init |/
S3c2440_lcdcon2_vspw_init)

// Lcdcon3
# Define s3c2440_lcdcon3_hbpd_init (38-1) <19)
# Define s3c2440_lcdcon3_hozval_init (320-1) <8)
# Define s3c2440_lcdcon3_hfpd_init (20-1)
# Define s3c2440_lcdcon3_init () (rlcdcon3 = s3c2440_lcdcon3_hbpd_init |/
S3c2440_lcdcon3_hozval_init |/
S3c2440_lcdcon3_hfpd_init)

// Lcdcon4
# Define s3c2440_lcdcon4_mval_init (0 <8)
# Define s3c2440_lcdcon4_hspw_init (30-1)
# Define s3c2440_lcdcon4_init () (rlcdcon4 = s3c2440_lcdcon4_mval_init |/
S3c2440_lcdcon4_hspw_init)

// Lcdcon5
# Define s3c2440_lcdcon5_bpp24bl_init (0 <12)
# Define s3c2440_lcdcon5_invvclk_init (1 <10)/* vclk rising edge */
# Define s3c2440_lcdcon5_invvline_init (1 <9)
# Define s3c2440_lcdcon5_pwren_init (1 <3)
# Define s3c2440_lcdcon5_enlend_init (1 <2)
# Define s3c2440_lcdcon5_init () (rlcdcon5 = s3c2440_lcdcon5_bpp24bl_init |/
S3c2440_lcdcon5_invvclk_init |/
S3c2440_lcdcon5_invvline_init |/
S3c2440_lcdcon5_pwren_init |/
S3c2440_lcdcon5_enlend_init)

// Lcdsaddr
Void set_lcdsaddr (u32 ADDR)
{
Rlcdsaddr1 = (ADDR> 1) & 0x3fffffff;
Rlcdsaddr2 = (rlcdsaddr1 & 0x1fffff) + (LCD _width * 32/16) * 240;
Rlcdsaddr3 = (0 <11) | (LCD _width * 32/16); // width * number of digits per pixel/16
}


Void tft_lcd35_init (void) // Initialization
{
Int A, B;
 
For (B = 0; B <LCD _high; B ++)
For (A = 0; A <LCD _width; A ++)
LCD _buffer [B] [a] = 0x000066;
 
// Configure related pins
Rgpcup = 0 xFFFF;
Rgpccon = 0 xaaaaaaaa;
Rgpdup = 0 xFFFF;
Rgpdcon = 0 xaaaaaaaa; // VD [8] ~ VD [23]
Rgpgup = rgpgup &(~ (1 <4) | (1 <4 );
Rgpgcon = rgpgcon &(~ (3 <8) | (3 <8); // LCD _pwren
 
// Set the display address
Set_lcdsaddr (u32) LCD _buffer );
 
// Configure lcdcon
S3c2440_lcdconw.init ();
S3c2440_lcdcon2_init ();
S3c2440_lcdcon3_init ();
S3c2440_lcdcon4_init ();
S3c2440_lcdcon5_init ();
 
Rlcdintmsk | = (3); // shielded LCD interrupt
Rtconsel = 0; // The value of lcc3600 and lpc3600 is invalid.
 
// Rtpal = 0x1cc0000; // use a temporary color palette.

Rlcdcon1 | = 1; // LCD Enabled

}

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.