TQ2440 Study Notes—— 25. LCD Controller

Publisher:alpha12Latest update time:2022-04-21 Source: eefocusKeywords:TQ2440  LCD  controller Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

         * The frame memory is completely consistent with the viewpoint,

         * The image data format is as follows (at 8BPP, the data in the frame buffer is the index value in the palette):

         *         |----PAGEWIDTH----|

         * y/x 0 1 2 639

         *     0   idx idx idx ... idx

         *     1   idx idx idx ... idx

         * 1. LCDSADDR1:

         * Set LCDBANK, LCDBASEU

         * 2. LCDSADDR2:

         * Set LCDBASEL: frame buffer end address A[21:1]

         * 3. LCDSADDR3:

         * OFFSIZE is equal to 0, PAGEWIDTH is equal to (640/2)

         */

        LCDSADDR1 = ((LCDFRAMEBUFFER>>22)<<21) | LOWER21BITS(LCDFRAMEBUFFER>>1);

        LCDSADDR2 = LOWER21BITS((LCDFRAMEBUFFER+

                    (LINEVAL_TFT_640480+1)*(HOZVAL_TFT_640480+1)*1)>>1);

        LCDSADDR3 = (0<<11) | (LCD_XSIZE_TFT_640480/2);

 

        /* Disable temporary palette register */

        TPAL = 0;

 

        fb_base_addr = LCDFRAMEBUFFER;

        bpp = 8;

        xsize = 640;

        ysize = 480;

        

        break;

        

    case MODE_TFT_16BIT_640480:

        /* 

         * Set the LCD controller's control registers LCDCON1~5

         * 1. LCDCON1:

         * Set the frequency of VCLK: VCLK(Hz) = HCLK/[(CLKVAL+1)x2]

         * Select LCD type: TFT LCD   

         * Set display mode: 16BPP

         * Disable LCD signal output first

         * 2. LCDCON2/3/4:

         * Set the time parameters of the control signal

         * Set the resolution, i.e. the number of rows and columns

         * Now, the display frequency can be calculated according to the formula:

         * When HCLK=100MHz,

         * Frame Rate = 1/[{(VSPW+1)+(VBPD+1)+(LIINEVAL+1)+(VFPD+1)}x

         *              {(HSPW+1)+(HBPD+1)+(HFPD+1)+(HOZVAL+1)}x

         * {2x(CLKVAL+1)/(HCLK)}]

         *            = 60Hz

         * 3. LCDCON5:

         * Data format when setting display mode to 16BPP: 5:6:5

         * Set the polarity of HSYNC and VSYNC pulses (this needs to refer to the specific LCD interface signal): Invert

         * Halfword (2-byte) swap enable

         */

        LCDCON1 = (CLKVAL_TFT_640480<<8) | (LCDTYPE_TFT<<5) |

                  (BPPMODE_16BPP<<1) | (ENVID_DISABLE<<0);

        LCDCON2 = (VBPD_640480<<24) | (LINEVAL_TFT_640480<<14) |

                  (VFPD_640480<<6) | (VSPW_640480);

        LCDCON3 = (HBPD_640480<<19) | (HOZVAL_TFT_640480<<8) | (HFPD_640480);

        LCDCON4 = HSPW_640480;

        LCDCON5 = (FORMAT8BPP_565<<11) | (HSYNC_INV<<9) | (VSYNC_INV<<8) |

                  (HWSWP<<1);

 

        /*

         * Set the LCD controller address register LCDSADDR1~3

         * The frame memory is completely consistent with the viewpoint,

         * The image data format is as follows:

         *         |----PAGEWIDTH----|

         * y/x 0 1 2 639

         *     0   rgb rgb rgb ... rgb

         *     1   rgb rgb rgb ... rgb

         * 1. LCDSADDR1:

         * Set LCDBANK, LCDBASEU

         * 2. LCDSADDR2:

         * Set LCDBASEL: frame buffer end address A[21:1]

         * 3. LCDSADDR3:

         * OFFSIZE is equal to 0, PAGEWIDTH is equal to (640*2/2)

         */

        LCDSADDR1 = ((LCDFRAMEBUFFER>>22)<<21) | LOWER21BITS(LCDFRAMEBUFFER>>1);

        LCDSADDR2 = LOWER21BITS((LCDFRAMEBUFFER+

                    (LINEVAL_TFT_640480+1)*(HOZVAL_TFT_640480+1)*2)>>1);

        LCDSADDR3 = (0<<11) | (LCD_XSIZE_TFT_640480*2/2);

 

        /* Disable temporary palette register */

        TPAL = 0;

 

        fb_base_addr = LCDFRAMEBUFFER;

        bpp = 16;

        xsize = 640;

        ysize = 480;

 

        break;

 

    default:

        break;

    }   

}

 

/*

 * Set the color palette

 */

void Lcd_Palette8Bit_Init(void)

{

    int i;  

    volatile unsigned int *palette;

 

LCDCON1 &= ~0x01; // stop lcd controller

    

    LCDCON5 |= (FORMAT8BPP_565<<11); // Set the data format in the palette to 5:6:5

 

    palette = (volatile unsigned int *)PALETTE;

    for (i = 0; i < 256; i++)

        *palette++ = DEMO256pal[i];

 

LCDCON1 |= 0x01; // re-enable lcd controller

}

 

/*

 * Change the palette to a single color

 * Input parameters:

 * color: color value, format is 0xRRGGBB

 */

void ChangePalette(UINT32 color)

{

    int i;

    unsigned char red, green, blue;

    UINT32 *palette;

 

red   = (color >> 19) & 0x1f;

green = (color >> 10) & 0x3f;

blue  = (color >>  3) & 0x1f;

color = (red << 11) | (green << 5) | blue; // 格式5:6:5

    

    palette=(UINT32 *)PALETTE;

LCDCON1 &= ~0x01; // stop lcd controller

    for (i = 0; i < 256; i++)

    {

// while (((LCDCON5>>15) & 0x3) == 2); // Wait until VSTATUS is not "valid"

        *palette++ = color;

    }

LCDCON1 |= 0x01; // re-enable lcd controller

}

 

/*

 * Set whether to output LCD power switch signal LCD_PWREN

 * Input parameters:

 * invpwren: 0 - Normal polarity when LCD_PWREN is valid

 * 1 - Invert polarity when LCD_PWREN is active

 * pwren: 0 - LCD_PWREN output is valid

 * 1 - LCD_PWREN output is disabled

 */

void Lcd_PowerEnable(int invpwren, int pwren)

{

    GPGCON = (GPGCON & (~(3<<8))) | (3<<8);   // GPG4用作LCD_PWREN

    GPGUP = (GPGUP & (~(1<<4))) | (1<<4); // Disable internal pull-up    

        

    LCDCON5 = (LCDCON5 & (~(1<<5))) | (invpwren<<5); // Set LCD_PWREN polarity: normal/inverted

    LCDCON5 = (LCDCON5 & (~(1<<3))) | (pwren<<3); // Set whether to output LCD_PWREN

}    

 

/*

 * Set whether the LCD controller outputs a signal

 * Input parameters:

 * onoff: 

 * 0 : Disable

 * 1 : Open

 */

void Lcd_EnvidOnOff(int onoff)

{

    if (onoff == 1)

    {

        LCDCON1 |= 1;         // ENVID ON

    }

    else

    {

        LCDCON1 &= 0x3fffe;  // ENVID Off

    }

}    

 

/*

 * Output monochrome images using temporary palette registers

 * Input parameters:

 * color: color value, format is 0xRRGGBB

 */

void ClearScrWithTmpPlt(UINT32 color)

{

    TPAL = (1<<24)|((color & 0xffffff)<<0);

}

 

/*

 * Stop using temporary palette registers

 */

void DisableTmpPlt(void)

{

    TPAL = 0;

}

————————————————

Copyright Statement: This article is an original article by CSDN blogger "Cawen_Cao" and follows the CC 4.0 BY-SA copyright agreement. Please attach the original source link and this statement when reprinting.

Original link: https://blog.csdn.net/Cowena/article/details/48207173


[1] [2]
Keywords:TQ2440  LCD  controller Reference address:TQ2440 Study Notes—— 25. LCD Controller

Previous article:TQ2440 Study Notes —— 21. Interrupt Architecture
Next article:TQ2440 Study Notes—— 31. Transplanting U-Boot [Source code analysis of the second stage of U-Boot's startup process]

Recommended ReadingLatest update time:2024-11-16 22:34

Programming of 12864 LCD display-button electronic clock based on 51 single chip microcomputer
//The LCD screen is JM12864 or FYD12864 (with font library). I have no problem using these two types of screens. 4 rows * 8 columns of Chinese characters = 32 serial communication interfaces P1.5--P1.7. You can modify the corresponding interfaces according to your circuit. #include reg52.h #include intrins.h #define
[Microcontroller]
MCU tutorial: 51 MCU infrared remote control and display on LCD1602
#include #include intrins.h typedef unsigned int uint; typedef  unsigned char uchar; sbit LCD_RS=P2^0; sbit LCD_RW=P2^1; sbit LCD_EN=P2^2; sbit IRINPUT=P3^2;   uchar code Display_LINE0 ={"VALUE FROM IR:   "}; uchar   Display_LINE1 ={"IR CODE:       H     "}; uchar IR_Input_Buffer ; uchar Display_Buffe
[Microcontroller]
OK6410A Development Board (IV) 1 OK6410A Bare Metal LCD RGB Interface
The code has been uploaded to the repository: https://github.com/lisider/OK6410/tree/master/lcd hardware LCD controller side 14 Display Controller // Located in S3C6410 datasheet Page 455 Register range: 0x77100000 - 0x77100344 Number of registers: 105 Hardware interface: Support RGB and three other interfaces (I80
[Microcontroller]
Using STM32CubeMX for STM32F429 LCD Programming Global Configuration
illustrate: The following programs all take the library in STM32Cube_FW_F4_V1.16.0 as an example. The STM32CubeMX version number is STM32CubeMX 4.22.0. The LCD is 1024 x 768 15-inch LCD. Use SDRAM as LCD frame buffer. The overall pin configuration diagram of the STM32CubeMX chip is as follows: 1. STM32F429 LTDC int
[Microcontroller]
Detailed explanation of 51 single chip microcomputer LCD1602 program
LCD1602  industrial character LCD. 1602 means the content displayed by the LCD is 16X2, that is, it can display two lines, 16 characters per line. Special interface description  RS: register selection input  RS=1: points to data register  RS=0: points to instruction register RW: Read/write control input  RW=0: write o
[Microcontroller]
Stm32 TFT LCD display control study notes
Learning STM32, TFT LCD display control is a very important chapter. I encountered many difficulties in the initial learning of STM32, so I listed some important knowledge points accumulated in the study. At present, the commonly used TFT LCD internal driver chips are ILI9320 and ILI9325 series. The internal principles
[Microcontroller]
C51 MCU Programming Skills: LCD1602 Programming Experience Sharing
Introduction: Let me first explain that the chip driver of the LCD1602 I am going to talk about below is HD44780. If your LCD1602 driver chip is not HD44780, then the following content is not applicable. This time I will share my LCD1602 programming experience: Let me first explain that the chip driver of the LCD160
[Microcontroller]
C51 MCU Programming Skills: LCD1602 Programming Experience Sharing
Designing LCD Display Power Supply Circuit Using TOPSwitch-HX
Designing LCD Display Power Supply Circuit Using TOPSwitch-HX
[Power Management]
Designing LCD Display Power Supply Circuit Using TOPSwitch-HX
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号