<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 12232F用串口的顯示程序

          12232F用串口的顯示程序

          作者: 時間:2016-11-18 來源:網(wǎng)絡(luò) 收藏
          這是12232F串口顯示程序,該程序可以通過調(diào)用函數(shù)可在任意位置顯示任意字符,供大家參考。


          /* 第一行起始地址為0x80
          第二行起始地址為0x90 */
          #include
          #include "INTRINS.H"

          本文引用地址:http://www.ex-cimer.com/article/201611/315571.htm

          #define comm 1
          #define dat 0
          #define uint unsigned int
          #define uchar unsigned char

          sbit CS = P0^2;
          sbit CLK = P0^0;
          sbit STD = P0^1;


          unsigned char code Chinese [] = {"歡迎使用"};

          void delay ()
          {
          unsigned int i;
          for (i=0;i<1500;i++);
          }

          void Write_Byte (unsigned char Data)
          {
          unsigned char i;
          CLK = 0;
          _nop_();
          _nop_();
          for (i=8;i>0;i--)
          {
          Data <<= 1;
          STD = CY;
          CLK = 0;
          _nop_();
          _nop_();
          _nop_();
          CLK = 1;
          _nop_();
          _nop_();
          }
          }

          void Write_12232 (unsigned char Derect,unsigned char Hight)
          {
          CS = 0;
          _nop_();
          _nop_();
          _nop_();
          CS = 1;
          if(Derect==1)
          Write_Byte (0xf8); //命令字
          else
          Write_Byte (0xfa);
          Write_Byte (Hight&0xf0); //數(shù)據(jù)字
          Hight &= 0x0f;
          Write_Byte (Hight<<=4);
          CS = 0;
          }
          //該函數(shù)用于在指定位置顯示字符串,x為行數(shù),y為列,k為字符個數(shù)
          void lcd_char(uchar x,uchar y,uchar k,uchar *datt)
          {
          uchar addr,i;
          if(x==0)
          addr=0x80+y;
          else
          addr=0x90+y;
          Write_12232 (comm,addr);
          for(i=0;i Write_12232 (dat,datt[i]);
          }
          //在指定位置顯示漢字串,其中x為行坐標,y為列坐標,k為所要顯示的漢字個數(shù)
          void Write_Chinese (uchar x,uchar y,uchar k,uchar *p)
          {
          uchar addr,i;
          if(x==0)
          addr=0x80+y;
          else
          addr=0x90+y;
          Write_12232 (comm,addr);
          for (i=0;i<2*k;i++)
          Write_12232 (dat,p [i]);

          }

          void init_lcd()
          {
          CS = 0;
          Write_12232 (comm,0x08);//關(guān)顯示
          delay ();
          Write_12232 (comm,0x10);//設(shè)置光標為右移
          delay ();
          Write_12232 (comm,0x06);//設(shè)置光標整體右移時AC加1
          delay ();
          Write_12232 (comm,0x02);//地址歸位
          delay ();
          Write_12232 (comm,0x01);//清除顯示
          delay ();
          Write_12232 (comm,0x0c);//開顯示,不顯示光標,光標不反白顯示
          }

          void main ()
          { uchar b[4];
          P0M1=0X00;
          P0M0=0X00;
          b[0]=5+0x30;
          b[1]=6+0x30;
          b[2]=0x37;
          b[3]=0x38;
          init_lcd();
          lcd_char(0,2,4,b);
          Write_Chinese (1,0,4,Chinese);
          delay ();
          while (1)
          {
          }
          }



          關(guān)鍵詞: 12232F串口顯示程

          評論


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

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();