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

          新聞中心

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

          STC89C52單片機(jī)12864液晶顯示

          作者: 時(shí)間:2016-11-21 來源:網(wǎng)絡(luò) 收藏
          ///////////////////////////////////////////////////////////////////////

          實(shí)現(xiàn)功能:在實(shí)驗(yàn)板上所佩帶的LCD12864上顯示想顯示的漢字,達(dá)到學(xué)習(xí)操作
          12864的目的
          實(shí)驗(yàn)板型號:KBL-XYD-C52
          實(shí)驗(yàn)名稱: lcd12864漢字顯示實(shí)驗(yàn)
          編寫人: 謝應(yīng)東
          編寫日期: 2012-5-3
          ///////////////////////////////////////////////////////////////////////
          #include

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

          #define uchar unsigned char
          #define uint unsigned int

          #define Lcd_IO P0
          #define Commd 0
          #define Data 1

          sbit LCDRS=P3^4; //12864是數(shù)據(jù)選擇端還是指令選擇端
          sbit LCDRW=P3^5; //12864的讀寫操作端
          sbit LCDEN=P3^6; //12864的使能端
          sbit LCDPSB=P3^7; //選擇12864是并行輸入還是串行輸入

          sbit wei=P2^7; //定義數(shù)碼管的位選
          sbit duan=P2^6; //定義數(shù)碼管的段選

          //一幅公雞圖形數(shù)據(jù)
          uchar code Lcd_num[]={
          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
          0x00,0x70,0x00,0x70,0xC0,0x02,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
          0x00,0x70,0x00,0x70,0xC0,0x0F,0x03,0x00,0x3F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
          0x00,0xF8,0x00,0x70,0xC0,0xFF,0x83,0x00,0xC0,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
          0x00,0xE8,0x03,0xFE,0xC0,0x1C,0x03,0x03,0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,
          0x01,0xCC,0x00,0x70,0xC0,0x1C,0x33,0x04,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,
          0x01,0xC7,0x00,0x76,0xDC,0x1C,0x33,0x08,0x00,0x01,0x00,0x00,0x00,0xE0,0x30,0x00,
          0x03,0x87,0x87,0x7F,0xFC,0x1C,0x33,0x18,0x06,0x0C,0xE0,0x00,0x00,0xC0,0x30,0x00,
          0x07,0x03,0xF7,0xFF,0xFC,0xFF,0xB3,0x10,0x06,0x1D,0xC0,0x00,0x00,0xC0,0x30,0x00,
          0x0C,0x01,0xE7,0xFE,0xDC,0xFF,0xB3,0x20,0x0E,0x3A,0xF0,0x00,0x00,0xC0,0x70,0x00,
          0x1F,0xFF,0xE7,0x0E,0xDC,0x1C,0x33,0x20,0x0E,0x31,0xD0,0x00,0x01,0xC0,0x70,0x00,
          0x2F,0xFF,0xA3,0x04,0xDC,0x3C,0x33,0x20,0x0E,0x70,0x60,0x00,0x01,0xC0,0x70,0x00,
          0x00,0x70,0x03,0xFC,0xDC,0x3E,0x33,0x40,0x0C,0xE0,0x00,0x00,0x01,0xC0,0x60,0x00,
          0x00,0x70,0x00,0x18,0xDC,0x3F,0x33,0x40,0x0C,0xC1,0x9F,0xC3,0xD9,0xBC,0x6E,0x1C,
          0x00,0x70,0x00,0x70,0xDC,0x3F,0x33,0x40,0x1D,0x81,0x9F,0xE7,0xF9,0xFC,0x6E,0x18,
          0x1F,0xFF,0xE0,0xF2,0xDC,0x7F,0x33,0x40,0x1F,0x81,0x98,0xE7,0x39,0x8E,0xE6,0x38,
          0x1F,0xFF,0xE0,0x76,0xDC,0x7D,0x33,0x40,0x1F,0x03,0x98,0xEE,0x33,0x8E,0xE6,0x30,
          0x08,0x70,0x00,0x7C,0xDC,0x5C,0x33,0x20,0x1F,0x83,0xB8,0xCE,0x33,0x8C,0xE6,0x30,
          0x0C,0x71,0x87,0xF8,0xDC,0xDC,0x33,0x20,0x1B,0x83,0x38,0xCE,0x33,0x0C,0xC6,0x60,
          0x06,0x71,0x07,0xF1,0xDC,0x9C,0x33,0x20,0x19,0x83,0x38,0xCC,0x33,0x0C,0xC6,0x60,
          0x07,0x73,0x07,0x71,0xDD,0x9C,0x03,0x10,0x39,0xC3,0x31,0xCC,0x73,0x1C,0xC6,0xC0,
          0x03,0x72,0x00,0x71,0x9C,0x1C,0x03,0x18,0x39,0xC3,0x31,0xCC,0x77,0x1D,0xC6,0xC0,
          0x03,0x76,0x00,0x71,0x9C,0x1C,0x03,0x08,0x39,0xC7,0x31,0xDC,0x67,0x1D,0xC7,0x80,
          0x02,0x74,0x00,0x73,0x1C,0x1C,0x03,0x04,0x38,0xE7,0x71,0x9C,0xE7,0x39,0x83,0x80,
          0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
          0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
          0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x00,
          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0x00,0x06,0x00,
          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0xC0,0x00,0x0C,0x00,
          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0xC0,0x00,0x0C,0x00,
          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0x80,0x00,0x18,0x00,
          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
          0x00,0x01,0x00,0x30,0x00,0x05,0x04,0x84,0x00,0x00,0x00,0x01,0x04,0x00,0x14,0x00,
          0x00,0x11,0x10,0x08,0x00,0x04,0x82,0x48,0x1F,0xF0,0x00,0x00,0x84,0x00,0x12,0x00,
          0x00,0x1F,0xF0,0x04,0x00,0x04,0x0F,0xFE,0x00,0x10,0x00,0x00,0x04,0x00,0x10,0x00,
          0x00,0x00,0x40,0x04,0x03,0xFF,0x88,0x02,0x08,0x10,0x00,0x03,0xE7,0x8F,0xFE,0x00,
          0x00,0x12,0x40,0x0A,0x00,0x04,0x03,0xF8,0x04,0x10,0x00,0x00,0x04,0x00,0x10,0x00,
          0x00,0x3F,0x78,0x0A,0x00,0x04,0x00,0x10,0x02,0x10,0x00,0x02,0x44,0x00,0x10,0x00,
          0x00,0x12,0x88,0x0A,0x01,0xF4,0x00,0x20,0x00,0x50,0xFF,0xE1,0x5F,0x87,0xD0,0x00,
          0x00,0x12,0x20,0x11,0x00,0x44,0x0F,0xFE,0x01,0x90,0x00,0x01,0x50,0x81,0x10,0x00,
          0x00,0x1E,0x20,0x11,0x00,0x42,0x00,0x40,0x06,0x10,0x00,0x00,0x90,0x81,0x08,0x00,
          0x00,0x12,0x50,0x20,0x80,0x42,0x80,0x40,0x38,0x10,0x00,0x00,0xD0,0x81,0x0A,0x00,
          0x00,0x12,0x50,0x40,0x40,0x79,0x80,0x40,0x00,0x10,0x00,0x03,0x1F,0x81,0xE6,0x00,
          0x00,0x1E,0x88,0x80,0x23,0x80,0x81,0xC0,0x00,0xE0,0x00,0x00,0x10,0x8E,0x02,0x00,
          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
          0x00,0x00,0x11,0xF0,0x04,0x00,0x40,0x00,0x80,0x13,0xE0,0x51,0x00,0x20,0x00,0x00,
          0x00,0x00,0x1C,0x90,0x04,0x00,0x20,0x1F,0xFC,0x12,0x20,0x51,0x07,0xFF,0x00,0x00,
          0x00,0x00,0x24,0x91,0x3F,0x87,0xFF,0x11,0x04,0x13,0xE0,0x91,0x01,0x04,0x00,0x00,
          0x00,0x00,0x49,0x30,0x84,0x80,0x80,0x0F,0xF8,0x7E,0x20,0xBF,0x80,0x88,0x00,0x00,
          0x00,0x00,0x3E,0x00,0x04,0x80,0x80,0x02,0x20,0x13,0xE1,0x91,0x03,0xFE,0x00,0x00,
          0x00,0x00,0x2A,0xA0,0x04,0x80,0xFE,0x01,0xC0,0x10,0x00,0x91,0x02,0x52,0x00,0x00,
          0x00,0x00,0x3E,0xF0,0x7F,0xC0,0x82,0x1E,0x38,0x1B,0xF0,0x91,0x02,0x8A,0x00,0x00,
          0x00,0x00,0x2B,0x20,0x04,0x00,0x82,0x00,0x80,0x70,0x80,0xFF,0xC3,0x76,0x00,0x00,
          0x00,0x00,0x3E,0x20,0x8A,0x01,0x02,0x1F,0xFC,0x12,0xE0,0x80,0x02,0x52,0x00,0x00,
          0x00,0x00,0x2A,0xF1,0x0A,0x01,0x02,0x02,0xA0,0x12,0x80,0x91,0x02,0x72,0x00,0x00,
          0x00,0x00,0x2A,0x20,0x11,0x02,0x02,0x04,0x90,0x12,0x80,0xA0,0x82,0x02,0x00,0x00,
          0x00,0x00,0x46,0x20,0x60,0xC4,0x1C,0x18,0x8C,0x35,0xF0,0xC0,0x42,0x06,0x00,0x00,
          0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
          };
          ///////////////////////////////////////////////////////////////////////
          函數(shù)名稱:DelayUs
          函數(shù)功能:讓單片機(jī)延時(shí)10us,即當(dāng)iNumber=10時(shí),延時(shí)為100us
          參數(shù)介紹:iNumber:定義要延時(shí)10us的次數(shù)
          返回值:
          注意事項(xiàng):無
          ///////////////////////////////////////////////////////////////////////
          void DelayUs(uint iNumber)
          {
          for(;iNumber>0;iNumber--);
          }
          ///////////////////////////////////////////////////////////////////////
          函數(shù)名稱:毫秒延時(shí)函數(shù)
          函數(shù)功能:實(shí)現(xiàn)毫秒級的延時(shí)
          參數(shù)介紹:Delay_MS: 定義需要延時(shí)的毫秒的數(shù)值
          iNumber: 記錄Delay_MS的數(shù)值,以for語句實(shí)現(xiàn)所要求的延時(shí)
          iValue: 要延時(shí)毫秒所要進(jìn)行的循環(huán)數(shù)值,本數(shù)值為實(shí)際測得
          返回值:
          注意事項(xiàng):本實(shí)驗(yàn)是在所用晶振為12M的前提下實(shí)現(xiàn)的毫秒延時(shí),本函數(shù)是通過循環(huán)的形
          式完成,所以如果改變了晶振的頻率,請做相應(yīng)的改變
          ///////////////////////////////////////////////////////////////////////
          void DelayMs(uint Delay_MS)
          {
          uint iNumber,iValue;
          for(iNumber=0;iNumber{
          iValue=107;
          while(iValue--);
          }
          }
          ///////////////////////////////////////////////////////////////////////
          函數(shù)名稱:WriteLCD_CommdData
          函數(shù)功能:向12864寫入一條命令或一個(gè)字節(jié)的數(shù)據(jù)
          參數(shù)介紹:cCommd:選擇是寫入命令了還是數(shù)據(jù),當(dāng)cCommd=1時(shí),為命令,cCommd=0相反
          返回值: cData:要寫入的命令或數(shù)據(jù)
          注意事項(xiàng):無
          ///////////////////////////////////////////////////////////////////////
          void WriteLCD_CommdData(uchar cCommd,uchar cData)
          {
          if(cCommd)
          LCDRS=1; //數(shù)據(jù)
          else LCDRS=0; //命令
          Lcd_IO=cData;
          LCDRW=0;
          LCDEN=1;
          DelayUs(30);
          LCDEN=0;
          }
          ///////////////////////////////////////////////////////////////////////
          函數(shù)名稱:Init_LCD()
          函數(shù)功能:初始化12864液晶
          參數(shù)介紹:無
          返回值:
          注意事項(xiàng):初始化的具體過程請看12864的數(shù)據(jù)手冊
          ///////////////////////////////////////////////////////////////////////
          void Init_LCD() //液晶初始化
          {
          DelayUs(10); //外部復(fù)位
          LCDPSB=1; //選擇12864為并行模式
          WriteLCD_CommdData(Commd,0x30); //基本指令格式
          DelayUs(30);
          WriteLCD_CommdData(Commd,0x01); //液晶清屏
          DelayMs(30);
          WriteLCD_CommdData(Commd,0x06); //設(shè)置顯示格式,光標(biāo)位置
          WriteLCD_CommdData(Commd,0x0c);
          }
          //液晶自定義顯示
          void Lcd_define(uchar *str)
          {
          uint m,n;
          WriteLCD_CommdData(Commd,0x34); //設(shè)置位擴(kuò)展指令格式
          for(m=0;m<32;m++)
          {
          for(n=0;n<8;n++)
          {
          WriteLCD_CommdData(Commd,0x80+m); //寫縱坐標(biāo),00H--1FH
          WriteLCD_CommdData(Commd,0x80+n); //寫橫坐標(biāo),00H--07H
          WriteLCD_CommdData(Data,str[m*16+n*2]);
          WriteLCD_CommdData(Data,str[m*16+n*2+1]);//連續(xù)寫兩個(gè)數(shù)據(jù)
          }
          }

          for(m=32;m<64;m++)
          {
          for(n=0;n<8;n++)
          {
          WriteLCD_CommdData(Commd,0x80+m-32); //寫縱坐標(biāo),00H--1FH
          WriteLCD_CommdData(Commd,0x88+n); //寫橫坐標(biāo),08H--0FH
          WriteLCD_CommdData(Data,str[m*16+n*2]);
          WriteLCD_CommdData(Data,str[m*16+n*2+1]); //連續(xù)寫兩個(gè)數(shù)據(jù)
          }
          }
          WriteLCD_CommdData(Commd,0x30); //基本指令格式
          WriteLCD_CommdData(Commd,0x01); //清屏
          DelayMs(30);
          WriteLCD_CommdData(Commd,0x34); //擴(kuò)展指令格式
          WriteLCD_CommdData(Commd,0x36); //顯示自定義圖形
          }
          //主函數(shù)
          void main()
          {
          wei=1;
          P0=0XFF;
          wei=0;
          duan=1;
          P0=0x00;
          duan=0;

          Init_LCD();
          Lcd_define(Lcd_num);
          while(1);
          }



          評論


          技術(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); })();