在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<abbr id="27omo"></abbr>

<menu id="27omo"><dl id="27omo"></dl></menu>
    • <label id="27omo"><tt id="27omo"></tt></label>

      新聞中心

      EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > PIC單片機(jī)12864漢字液晶模塊顯示文字

      PIC單片機(jī)12864漢字液晶模塊顯示文字

      作者: 時(shí)間:2018-08-01 來源:網(wǎng)絡(luò) 收藏

      本文引用地址:http://www.biyoush.com/article/201808/384804.htm

      本文介紹了利用PIC12864漢字液晶模塊來顯示文字

      #include

      __CONFIG(0x1832);

      //芯片配置字,看門狗關(guān),上電延時(shí)開,掉電檢測關(guān),低壓編程關(guān),加密,4M晶體HS振蕩

      #define rs RA5 //定義LCD的數(shù)據(jù)/命令控制口

      #define rw RA4 //定義LCD的讀/寫控制口

      #define e RA3 //定義LCD的使能口

      #define psb RA2 //定義通信方式控制口

      #define rst RA0 //定義復(fù)位口

      #define nop() asm(nop) //定義nop()函數(shù)

      //深圳乾龍盛電子

      const unsigned char TAB1A[ ]={0xC9,0xEE,0xDB,0xDA,0xC7,0xAC,0xC1,0xFA,0xCA,0xA2,0xB5,0xE7,0xD7,0xD3};

      //WWW.PIC16.COM

      const unsigned char TAB1B[ ]={' ', ' ', 'W', 'W', 'W', '.', 'P', 'I', 'C', '1','6', '.', 'C', 'O', 'M', ' '};

      //TEL0755-28187975

      const unsigned char TAB1C[ ]={'T', 'E', 'L' ,'0' ,'7', '5' ,'5','-', '2', '8','1', '8' ,'7','9' ,'7','5'};

      //FAX0755-28187976

      const unsigned char TAB1D[ ]={'F', 'A', 'X', '0', '7', '5', '5', '-','2', '8','1', '8', '7', '9', '7', '6'};

      unsigned int lcd_x; //定義LCD頁地址寄存器

      unsigned int lcd_y; //定義LCD列地址寄存器

      bit busy; //定義LCD忙標(biāo)志位

      void init(); //申明I/O口設(shè)置函數(shù)

      void lcd_init(); //申明LCD初始化函數(shù)

      void clear_p(); //申明清屏函數(shù)

      void han_wr2a(); //申明顯示公司名稱函數(shù)

      void han_wr2b(); //申明顯示公司web函數(shù)

      void han_wr2c(); //申明顯示公司tel函數(shù)

      void han_wr2d(); //申明顯示公司fax函數(shù)

      void wr_zb(); //申明有關(guān)顯示設(shè)置函數(shù)

      void flash(); //申明設(shè)置LCD顯示閃爍函數(shù)

      void qushu(int counts,const unsigned char *ps); //申明查表獲取顯示數(shù)據(jù)

      void send_d(unsigned char x); //申明送一字節(jié)數(shù)據(jù)顯示函數(shù)

      void send_i(unsigned char x); //申明送一字節(jié)控制命令函數(shù)

      void chk_busy(); //申明檢測LCD是否工作繁忙函數(shù)

      void delay(); //申明延時(shí)函數(shù)1,供各命令之間的延時(shí)和決定顯示快慢

      void delay1(); //申明延時(shí)函數(shù)2,用以決定顯示閃爍快慢

      //-------------------------------------------

      //主程序

      void main()

      {

      while(1)

      {

      init(); //調(diào)用I/O口設(shè)置函數(shù)

      lcd_init(); //調(diào)用LCD初始化函數(shù)

      clear_p(); //調(diào)用清屏函數(shù)

      han_wr2a(); //調(diào)用顯示公司名稱函數(shù)

      han_wr2b(); //調(diào)用顯示公司web函數(shù)

      han_wr2c(); //調(diào)用顯示公司tel函數(shù)

      han_wr2d(); //申明顯示公司fax函數(shù)

      delay(); //延長顯示一段時(shí)間

      flash(); //調(diào)用顯示閃爍函數(shù)

      clear_p(); //調(diào)用清屏函數(shù)

      }

      }

      //-------------------------------------------

      //I/O口設(shè)置函數(shù)

      void init()

      {

      TRISA=0X00; //設(shè)置A口為輸出

      TRISD=0X00; //設(shè)置D口為輸出

      ADCON1=0X06; //設(shè)置A口為普通I/O口

      }

      //-------------------------------------------

      //LCD初始化函數(shù)

      void lcd_init()

      {

      rst=0; //復(fù)位LCD

      delay(); //保證復(fù)位所需要的時(shí)間

      rst=1; //恢復(fù)LCD正常工作

      nop();

      psb=1; //設(shè)置LCD為8位并口通信

      send_i(0x30); //基本指令操作

      send_i(0x01); //清除顯示

      send_i(0x06); //指定在寫入或讀取時(shí),光標(biāo)的移動(dòng)方向

      send_i(0x0c); //開顯示,關(guān)光標(biāo),不閃爍

      }

      //-------------------------------------------

      //顯示公司名稱函數(shù)

      void han_wr2a()

      {

      send_i(0x81); //設(shè)置顯示位置:第一行

      qushu(0xe,TAB1A); //調(diào)用取數(shù)函數(shù),共14個(gè)數(shù)據(jù),保存在數(shù)組TAB1A里

      }

      //-------------------------------------------

      //顯示公司web函數(shù)

      void han_wr2b()

      {

      send_i(0x90); //設(shè)置顯示位置:第二行

      qushu(0x10,TAB1B); //調(diào)用取數(shù)函數(shù),共16個(gè)數(shù)據(jù),保存在數(shù)組TAB1B里

      }

      //-------------------------------------------

      //顯示公司tel函數(shù)

      void han_wr2c()

      {

      send_i(0x88); //設(shè)置顯示位置:第三行

      qushu(0X10,TAB1C); //調(diào)用取數(shù)函數(shù),共16個(gè)數(shù)據(jù),保存在數(shù)組TAB1C里

      }

      //-------------------------------------------

      //顯示公司fax函數(shù)

      void han_wr2d()

      {

      send_i(0x98); //設(shè)置顯示位置:第四行

      qushu(0X10,TAB1D); //調(diào)用取數(shù)函數(shù),共16個(gè)數(shù)據(jù),保存在數(shù)組TAB1D里

      }

      //有關(guān)顯示設(shè)置函數(shù)

      void wr_zb()

      {

      send_i(lcd_y);

      send_i(lcd_x);

      }

      //-------------------------------------------

      //顯示閃爍函數(shù)

      void flash()

      {

      send_i(0x08); //關(guān)顯示

      delay1(); //延長一定時(shí)間

      send_i(0x0c); //開顯示

      delay1();

      delay1(); //延長關(guān)顯示兩倍的時(shí)間

      send_i(0x08); //關(guān)顯示

      delay1();

      send_i(0x0c); //開顯示

      delay1();

      delay1();

      send_i(0x08); //關(guān)顯示

      delay1();

      send_i(0x0c); //開顯示

      delay1();

      delay1();

      }

      //-------------------------------------------

      //清屏函數(shù)

      void clear_p()

      {

      send_i(0x1); //清除所有顯示

      send_i(0x34); //擴(kuò)展指令操作

      send_i(0x30); //基本指令操作

      }

      //------------------------------------------

      //查表函數(shù)

      void qushu(int counts,const unsigned char *ps)

      {

      int i; //定義循環(huán)變量

      for(i=counts;i>0;i--) //循環(huán)counts次

      {

      send_d(*ps); //查表取數(shù)并調(diào)用顯示一個(gè)字節(jié)數(shù)據(jù)函數(shù)送顯示

      delay(); //延長一定時(shí)間,確保能看到數(shù)據(jù)一個(gè)個(gè)的顯示出來

      ps++; //取下一個(gè)數(shù)據(jù)

      }

      }

      //-------------------------------------------

      //顯示一字節(jié)數(shù)據(jù)函數(shù)

      void send_d(unsigned char x)

      {

      chk_busy(); //檢測LCD是否工作繁忙

      rs=1; //設(shè)置該字節(jié)數(shù)據(jù)是顯示數(shù)據(jù)

      rw=0; //設(shè)置該次操作為寫

      PORTD=x; //送數(shù)據(jù)口PORTD

      e=1; //使能

      nop();

      nop();

      nop();

      e=0; //禁止

      }

      //--------------------------------------------

      //送一字節(jié)命令代碼函數(shù)

      void send_i(unsigned char x)

      {

      chk_busy(); //檢測LCD是否工作繁忙

      rs=0; //設(shè)置該字節(jié)數(shù)據(jù)為控制命令

      rw=0; //設(shè)置此次操作為寫

      PORTD=x; //送數(shù)據(jù)口PORTD

      e=1; //使能

      nop();

      nop();

      nop();

      e=0; //禁止

      }

      //-------------------------------------------

      //檢測LCD是否工作繁忙

      void chk_busy()

      {

      busy=1; //先置位繁忙標(biāo)志位

      TRISD=0XFF; //更改通信為輸入

      rs=0; //設(shè)置該字節(jié)數(shù)據(jù)為命令代碼

      rw=1; //設(shè)置此次操作為讀

      while(busy)

      {

      nop();

      nop();

      nop();

      e=1; //使能

      nop();

      nop();

      nop();

      if(!RD7) busy=0; //檢測LCD是否工作繁忙

      nop();

      nop();

      nop();

      e=0; //禁止

      }

      e=0; //禁止

      TRISD=0X00; //恢復(fù)通信為輸出

      }

      //-------------------------------------------

      //延時(shí)函數(shù)

      void delay()

      {

      int i;

      for(i=0;i5000;i++)

      {;}

      }

      //-------------------------------------------

      //延時(shí)函數(shù)1

      void delay1()

      {

      int i;

      for(i=0;i10;i++)

      {

      delay(); //調(diào)用延時(shí)函數(shù)

      }

      }



      關(guān)鍵詞: 單片機(jī) 液晶顯示

      評論


      相關(guān)推薦

      技術(shù)專區(qū)

      關(guān)閉