Chinaunix首页 | 论坛 | 博客
  • 博客访问: 424344
  • 博文数量: 71
  • 博客积分: 1525
  • 博客等级: 上尉
  • 技术积分: 605
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-05 17:28
文章分类

全部博文(71)

文章存档

2012年(21)

2011年(50)

分类: LINUX

2011-10-11 12:40:01

液晶屏的显示设计需要专门设计驱动和显示控制电路。

在这个实验里,实验板的驱动和显示系统包括S3C2410X片内外设LCD控制器、液晶显示屏的驱动逻辑以及外围驱动电路。

S3C2410X处理器集成了 LCD控制器,主要功能是S3C2410X LCD 控制器用于传输显示数据和
产生控制信号。它并支持屏幕水平和垂直滚动显示。数据的传送采用DMA(直接内存访问)方式,
以达到最小的延迟。它可以支持多种液晶屏: STN,TFT

 

S3c2440芯片

  1. TFT_Init()初始化要做的工作:
    1. TFT_InitHardware硬件初始化
      1. Lcd_Port_Init():

        {

        rGPCUP = 0x00000000;//上拉电阻使能
        rGPCCON = 0xaaaa02a9; //这个与EMbest的代码不一样,VD[0:7],VM,VFRAME,VLINE,VCLK

        rGPDUP = 0x00000000;
        rGPDCON=0xaaaaaaaa; //Initialize VD[15:8]

        }

         

        rLCDCON1=(CLKVAL_TFT<<8)|(MVAL_USED<<7)|(3<<5)|(12<<1)|0;
                // TFT LCD panel,12bpp TFT,ENVID=off
            rLCDCON2=(VBPD<<24)|((LCD_YSIZE_TFT_320240 - 1)<<14)|(VFPD<<6)|(VSPW);
            rLCDCON3=(HBPD<<19)|((LCD_XSIZE_TFT_320240 - 1)<<8)|(HFPD);
            rLCDCON4=(MVAL<<8)|(HSPW);
            rLCDCON5 = (1<<11) | (1<<10) | (1<<9) | (1<<8) | (0<<7) | (0<<6) | (1<<3)  |(BSWP<<1) | (HWSWP);

            rLCDSADDR1=(((U32)LCD_BUFFER>>22)<<21)|M5D((U32)LCD_BUFFER>>1);
            rLCDSADDR2=M5D( ((U32)LCD_BUFFER+(SCR_XSIZE_TFT_320240*LCD_YSIZE_TFT_320240*2))>>1 );
            rLCDSADDR3=(((SCR_XSIZE_TFT_320240-LCD_XSIZE_TFT_320240)/1)<<11)|(LCD_XSIZE_TFT_320240/1);
            rLCDINTMSK|=(3); // MASK LCD Sub Interrupt
            rLPCSEL &= (~7) ;     // Disable LPC3480
            rTPAL=0; // Disable Temp Palette

       

    2. Lcd_PowerEnable(int invpwren, int pwren):
      //GPG4 is setted as LCD_PWREN
      rGPGUP=rGPGUP&(~(1<<4))|(1<<4); // Pull-up disable
      rGPGCON=rGPGCON&(~(3<<8))|(3<<8); //GPG4=LCD_PWREN
      //Enable LCD POWER ENABLE Function
      rLCDCON5=rLCDCON5&(~(1<<3))|(pwren<<3); // PWREN
      rLCDCON5=rLCDCON5&(~(1<<5))|(invpwren<<5); // INVPWREN
    3. Lcd_EnvidOnOff(int onoff)

      if(onoff==1)
              rLCDCON1|=1; // ENVID=ON
          else
              rLCDCON1 =rLCDCON1 & 0x3fffe; // ENVID Off

    4. TFT_ClearSrc()://清屏函数(黑屏)
      1. TFT_SetColor(COLOR_BLACK)  //设置屏幕颜色,为黑色

       

  2. 初始化后的程序:

    TFT_SetColor(COLOR_WHITE);
        Delay(1000);   
        TFT_SetColor(COLOR_RED);
        Delay(1000);
        TFT_SetColor(COLOR_GREEN);
        Delay(1000);
        TFT_SetColor(COLOR_BLUE);
        Delay(1000);
        TFT_SetColor(COLOR_YELLOW);
        Delay(1000);
        TFT_SetColor(COLOR_BLACK);
        Delay(500);
        TFT_PutPixel(20,20,COLOR_WHITE);
        TFT_PutPixel(60,20,COLOR_RED);
        TFT_PutPixel(40,20,COLOR_WHITE);
        TFT_PutPixel(80,20,COLOR_BLUE);
        TFT_PutPixel(100,20,COLOR_WHITE);
        TFT_PutPixel(120,20,COLOR_YELLOW);
        Delay(500);
        TFT_Line(30,30,300,30,COLOR_RED);
        Delay(500);
        TFT_Circle(50,100,35,COLOR_GREEN,PAINT_SOLID);
        Delay(500);
        TFT_Circle(200,200,30,COLOR_YELLOW,PAINT_HOLLOW);
        Delay(500);
        TFT_Rectangle(30,180,80,230,COLOR_BLUE,PAINT_SOLID);
        Delay(500);
        TFT_Rectangle(200,80,300,150,COLOR_WHITE,PAINT_HOLLOW);
        Delay(3000);

        TFT_Pitcure(0,0,320,240,Image);
        while(Uart_GetKey() != ESC_KEY);
        Uart_Printf("TFT Test End!\n");

    这个程序就在这里循环了,没有加入中断的处理。还缺少了对其他的控制寄存器进行处理

     

    以上是一个完整的程序了,下面是对上面程序的补充,控制寄存器的设置有些复杂啊!

    UINT32T (*frameBuffer8BitTft640480)[SCR_XSIZE_TFT_640480/4];

    #define LCDFRAMEBUFFER 0x31000000 //_NONCACHE_STARTADDRESS

    #define SCR_XSIZE_TFT_640480     (LCD_XSIZE_TFT_640480*2)

    #define LCD_XSIZE_TFT_640480     (640)

    #define CLKVAL_TFT_640480     (1)

    #define MVAL_USED     (0)

     

     

    frameBuffer8BitTft640480=(UINT32T (*)[SCR_XSIZE_TFT_640480/4])LCDFRAMEBUFFER;
                rLCDCON1=(CLKVAL_TFT_640480<<8)|(MVAL_USED<<7)|(3<<5)|(11<<1)|0;
                  
                   // TFT LCD panel,8bpp TFT,ENVID=off
                rLCDCON2=(VBPD_640480<<24)|(LINEVAL_TFT_640480<<14)|(VFPD_640480<<6)|(VSPW_640480);
                rLCDCON3=(HBPD_640480<<19)|(HOZVAL_TFT_640480<<8)|(HFPD_640480);
                rLCDCON4=(MVAL<<8)|(HSPW_640480);
                rLCDCON5=(1<<11)|(1<<9)|(1<<8);                     //FRM5:6:5,HSYNC and VSYNC are inverted
                rLCDSADDR1=(((UINT32T)frameBuffer8BitTft640480>>22)<<21)|M5D((UINT32T)frameBuffer8BitTft640480>>1);
                rLCDSADDR2=M5D( ((UINT32T)frameBuffer8BitTft640480+(SCR_XSIZE_TFT_640480*LCD_YSIZE_TFT_640480/1))>>1 );
                rLCDSADDR3=(((SCR_XSIZE_TFT_640480-LCD_XSIZE_TFT_640480)/2)<<11)|(LCD_XSIZE_TFT_640480/2);
                rLCDINTMSK|=(3);                                    // MASK LCD Sub Interrupt
                rLPCSEL&=(~7);                                      // Disable LPC3600
                rTPAL=0;                                            // Disable Temp Palette
          

阅读(2352) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~