<form id="lpvjh"><nobr id="lpvjh"><th id="lpvjh"></th></nobr></form>

<form id="lpvjh"></form>
<form id="lpvjh"><th id="lpvjh"></th></form>

<form id="lpvjh"></form>

<address id="lpvjh"></address>

    <span id="lpvjh"><th id="lpvjh"></th></span>

      文章詳情

      中文液晶模塊 240128 RA8822主控 樣例程序

      日期:2021-11-27 16:24
      瀏覽次數:845
      摘要:RA8822是一款帶中文字庫的液晶模塊驅動控制器,廣泛應用于液晶模塊的驅動控制,清達光電HG2401288采用了這種主控IC。

      RA8822是一款帶中文字庫的液晶模塊驅動控制器,廣泛應用于液晶模塊的驅動控制,清達光電HG2401288采用了這種主控IC。

      中文液晶模塊 240128 RA8822主控 樣例程序:

      //本程序為HG2401288 模塊的基本驅動程序
      //程序的顯示結果為:

      //“

      //清達光電科技有限公司 ”

      //“

      //HG2401288

      #include<stdio.h>
      #include<reg52.h>
      #include<intrins.h>
      #define uchar unsigned char
      #define uint  unsigned int
      #define lcd_bus  P1

      //sbit _CS=P3^2;
      sbit _CS=P3^3;
      sbit    RS=P3^4;
      sbit _WR=P3^0;
      sbit _RD=P3^1;
      sbit _RST=P3^5;
      sbit    buzy=P3^6;
      sbit    x=P3^3;

      //----------------------------
      //忙
      //----------------------------
      void busy()
      {
      while(buzy==1);
      }
      //----------------------------
      //延時子程序
      //----------------------------
      void Delay(uint m)
      {
      uint i;
      uint j;
      for(i=0;i<m;i++)
      for(j=0;j<109;j++);
      }
      //----------------------------
      //寫入寄存器地址或參數
      //----------------------------
      void writecom(uchar command)
      {
      busy();
      lcd_bus =command;
      _CS=0;
      RS=0;
      _WR=0;
      _WR=1;
      RS=1;
      _CS=1;
      }
      //----------------------------
      //寫入數據
      //----------------------------
      void writedat(uchar ddata)
      {
      busy();
      lcd_bus =ddata;
      _CS =0;
      RS=1;
      _WR=0;
      _nop_();_nop_();_nop_(); _nop_();
      _WR=1;
      RS=0;
      _CS=1;
      }
      //----------------------------
      //顯示文本
      //----------------------------
      void ShowText(uchar *text)
      {
      while(*text>0)
      {
      writedat(*text);
      text++;
      }}
      /**********************************************
        地址定義 ,x為一個字節,y為一行
      ********************************************/
      void xy(uchar x,uchar y)
      {
        uchar i;
        writecom(0x60);writecom(0x3f&x);
        writecom(0x70);writecom(0xff&y);
        _nop_();
      }
      //----------------------------
      //顯示文本
      //----------------------------
      void writeText(uchar x,uchar y,uchar *text)
      {
      xy(x,y);
      while(*text>0)
      {
      writedat(*text);
      text++; Delay(100);
      }
      }
      void writeText1(uchar x,uchar y,uchar *text)
      {
      xy(x,y);
      while(*text>0)
      {
      writedat(*text);
      text++; 
      }
      }
      /*********************************************
       初始化
      **********************************************/
      void Init()
      {
      _RST= 0;
      buzy=1;
      Delay(25);
      buzy=0;
      _RST= 1;
      Delay(100);
      writecom(0x00);writecom(0xcd);  //開電源,文本模式,開顯示,不閃爍,不反白
      writecom(0x01);writecom(0xf1);    // CLK_OUT 致能控制, 高觸發,4M
      writecom(0x02);writecom(0x10);    //60ns的讀取速度
      writecom(0x03);writecom(0x80);    //byte正常,com and seg不卷動
      writecom(0x10);writecom(0x68);    //中英問對齊,字體正常
      writecom(0x11);writecom(0x10);    // 光標高度為一,行距為0
      writecom(0x12);writecom(0x91);    //水平移動,選擇DDRAM1,

      writecom(0x20);writecom(0x1d);    // 工作窗右邊 29*8=232
      writecom(0x30);writecom(0x7f);    // 工作窗低邊 127
      writecom(0x40);writecom(0x00);    // 工作窗左邊 00
      writecom(0x50);writecom(0x00);    // 工作窗頂邊 00
      writecom(0x21);writecom(0x1d);    // 顯示窗右邊 29*8=232
      writecom(0x31);writecom(0x80);     // 顯示窗低邊 127
      writecom(0x41);writecom(0x00);     // 顯示窗左邊 00
      writecom(0x51);writecom(0x00);     // 顯示窗頂邊 00

      //writecom(0x80);writecom(0x33);   //光標閃爍時間設定,默認值
      writecom(0x81);writecom(0x40);   //  刷新頻率 ,默認值
      //writecom(0x81);writecom(0x00);   //  刷新頻率
      //writecom(0x91);writecom(0x00);   //  刷新頻率 ,默認值
      //writecom(0xd0);writecom(0x00);  //LCD 亮度控制(DAC 功能)
      //writecom(0x90);writecom(0x0a);
      writecom(0x90);writecom(0x12);   //XCK 訊號周期

      //writecom(0xf0);writecom(0x08);    //**命令  ,*好不用
      //writecom(0xe0);writecom(0x00);
      }
      //----------------------------
      //清屏
      //----------------------------
      void CleanScreen1(uchar m)
      {
      uchar i,j;
      writecom(0x00);writecom(0xc5);  //開電源,圖形模式,開顯示,不閃爍,不反白
      writecom(0x60);writecom(0x00);
      writecom(0x70);writecom(0x00);
      for(i=0;i<1;i++)
      { for(j=0;j<1;j++)
      writedat(m);
      }
      Delay(500);
      writecom(0x00);writecom(0xcd); //開電源,文本模式,開顯示,不閃爍,不反白
      }
      //----------------------------
      //清屏
      //----------------------------
      void CleanScreen(uchar m)
      {
      uchar i,j;
      writecom(0x00);writecom(0xc5);  //開電源,圖形模式,開顯示,不閃爍,不反白
      writecom(0x60);writecom(0x00);
      writecom(0x70);writecom(0x00);
      for(i=0;i<128;i++)
      {for(j=0;j<30;j++)
      writedat(m);
      }
      Delay(500);
      writecom(0x00);writecom(0xcd); //開電源,文本模式,開顯示,不閃爍,不反白
      }
      //----------------------------
      //隔點
      //----------------------------
      void dotScreen(uchar m)
      {
      uchar i,j;
      writecom(0x00);writecom(0xc5); //開電源,圖形模式,開顯示,不閃爍,不反白
      writecom(0x60);writecom(0x00);
      writecom(0x70);writecom(0x00);
      for(j=0;j<64;j++)
      {
      for(i=0;i<30;i++)
      writedat(m);
      for(i=0;i<30;i++)
      writedat(~m);
      }
      Delay(500);
      writecom(0x00);writecom(0xcd); //開電源,文本模式,開顯示,不閃爍,不反白
      }
      //----------------------------
      //邊框
      //----------------------------
      void biank()
      {
      uchar i,j;
      writecom(0x00);writecom(0xc5);//開電源,圖形模式,開顯示,不閃爍,不反白
      writecom(0x60);writecom(0x00);
      writecom(0x70);writecom(0x00);
      for(i=0;i<30;i++)
      {
      writedat(0xff);
      }

      writecom(0x60);writecom(0x00);
      writecom(0x70);writecom(0x7f);
      for(i=0;i<30;i++)
      {
      writedat(0xff);
      }

      writecom(0x12);writecom(0x11);  //先垂直移動再水平移動
      writecom(0x60);writecom(0x00);
      writecom(0x70);writecom(0x01);
      for(i=0;i<126;i++)
      {
      writedat(0x80);
      }

      writecom(0x60);writecom(0x3d);
      writecom(0x70);writecom(0x01);
      for(i=0;i<126;i++)
      {
      writedat(0x01);
      }
      writecom(0x12);writecom(0x91);
      writecom(0x00);writecom(0xcd); //開電源,文本模式,開顯示,不閃爍,不反白
      }
      /*******************************************************
       文本寫入
      *******************************************************/
      void text()
      {
      //biank();
      writecom(0xf1);writecom(0x1f);
      writecom(0x60);writecom(0x04);
      writecom(0x70);writecom(0x20);
      ShowText("清達光電");

      writecom(0xf1);writecom(0x0f);
      writecom(0x60);writecom(0x0c);
      writecom(0x70);writecom(0x30);
      ShowText("科技有限公司");

      writecom(0xf0);writecom(0xa0);
      writecom(0xf1);writecom(0x5f);
      writecom(0x10);writecom(0x79);
      writecom(0x60);writecom(0x06);
      writecom(0x70);writecom(0x40);
      ShowText("HG2401288");
      Delay(600);
        /*
      writecom(0x00);writecom(0xcc);  // 文本 反白顯示
      Delay(600);
      writecom(0x03);writecom(0xc4); // 設定Common 的自動卷動
      Delay(60000);


      writecom(0x00);writecom(0xcd);

      writecom(0xf1);writecom(0x0f);
      writecom(0x60);writecom(0x08);
      writecom(0x70);writecom(0x70);
      ShowText("杭州佳顯科技有限公司HANGZHOU.");
      Delay(6000);
       */
      }
      void tx11 () interrupt 3 using 2
      {
       if(~x)
       {
       Delay(60000);
      }
      }
      /*******************************************************
        向下卷動
      ************************************************************/
      void lcd_up()
      {
      uchar i;
      for(i=0;i<240;i++)
      {
      writecom(0x03);writecom(0xc4); // 設定Common 的自動卷動
      Delay(400);}
      }
      /*******************************************************
        向左卷動
      ************************************************************/
      void lcd_left()
      {
      uchar i,j;
      for(j=0;j<30;j++)
      {
       writecom(0x03);writecom(0xc3); // 設定seg 的自動卷動
       Delay(600);}
      }
      /*****************只能向左和想下卷動*****************************/

      //----------------------------
      //主程序
      //----------------------------
      main()
      {
        uchar i;
        IE=0X88;
        IP=0X08;
        IT0=0;
        Init();
        while(1)
        {
        CleanScreen(0x00);i=0;
       writecom(0xf0);writecom(0xa0);
       writecom(0xf1);writecom(0x0f);
       writeText(0,0,"清達光電提供內置中文字庫產品:直接提取中文和西文,控制器RA8822是一個雙圖層(Two Pages)中英文文字與繪圖模式的點矩陣液晶顯示(LCD)控制器,內建512K Byte 的字型碼,可以顯示中文字形,英日歐文字等字母,產品型號為:");
         
        writecom(0xf1);writecom(0x4f);
        writeText1(0,112,"HG2401288-F-LWH");
         Delay(1200);
       do
       {  
        CleanScreen(0x00);
       writecom(0xf0);writecom(0xa0);
       writecom(0xf1);writecom(0x4f);
       writeText1(2,0,"水平放大演示");
       
       writecom(0xf0);writecom(0xa0);
       writecom(0xf1);writecom(0x4f);
       writeText1(2,50,"豎直放大演示");
       
       writecom(0xf0);writecom(0xa0);
       writecom(0xf1);writecom(0x0f);
       writeText1(0,25,"2401288");
       
       writecom(0xf0);writecom(0xa0);
       writecom(0xf1);writecom(0x4f);
       writeText1(2,70,"2 4 0 1 2 8 8");  
        Delay(1200);
        
       writecom(0xf0);writecom(0xa0);
       writecom(0xf1);writecom(0x4f);
       writeText1(0,25,"2401288"); 
       writecom(0xf0);writecom(0xa0);
       writecom(0xf1);writecom(0x5f);
       writeText1(2,70,"2 4 0 1 2 8 8");
        Delay(1200);
        
       writecom(0xf0);writecom(0xa0);
       writecom(0xf1);writecom(0x8f);
       writeText1(0,25,"2401288");
       writecom(0xf0);writecom(0xa0);
       writecom(0xf1);writecom(0x6f);
       writeText1(2,70,"2 4 0 1 2 8 8");
        Delay(1200);
        
       writecom(0xf0);writecom(0xa0);
       writecom(0xf1);writecom(0xcf);
       writeText1(0,25,"2401288");
       writecom(0xf0);writecom(0xa0);
       writecom(0xf1);writecom(0x7f);
       writeText1(2,70,"2 4 0 1 2 8 8"); 
        Delay(1200);i++;}while(i<5);  
      }}


      新博体育