色婷婷AⅤ一区二区三区|亚洲精品第一国产综合亚AV|久久精品官方网视频|日本28视频香蕉

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 51單片機ST7565C語言驅(qū)動程序

          51單片機ST7565C語言驅(qū)動程序

          作者: 時間:2016-11-28 來源:網(wǎng)絡(luò) 收藏
          #include
          #include
          #defineuchar unsigned char
          #defineuint unsigned int
          /////////////////////////////////Serial///////////////////////////////////////////////////


          sbitR_S=P3^5;//指令/數(shù)據(jù)選擇信號
          sbitRES=P3^4;//復(fù)位信號
          sbitSCK=P1^6;
          sbitSDA=P1^7;
          sbitC_S=P3^7;//片選

          //////////////////////////////////////////////////////////////////////////////////////////////


          uchar Page = 0xb0;
          ///12345678910111213141516///
          unsigned char code Number[][16]={0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x0F,0x10,0x20,0x20,0x10,0x0F,0x00,//0
          0x00,0x10,0x10,0xF8,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,//1
          0x00,0x70,0x08,0x08,0x08,0x88,0x70,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,//2
          0x00,0x30,0x08,0x88,0x88,0x48,0x30,0x00,0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,//3
          0x00,0x00,0xC0,0x20,0x10,0xF8,0x00,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,//4
          0x00,0xF8,0x08,0x88,0x88,0x08,0x08,0x00,0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,//5
          0x00,0xE0,0x10,0x88,0x88,0x18,0x00,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,//6
          0x00,0x38,0x08,0x08,0xC8,0x38,0x08,0x00,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00,//7
          0x00,0x70,0x88,0x08,0x08,0x88,0x70,0x00,0x00,0x1C,0x22,0x21,0x21,0x22,0x1C,0x00,//8
          0x00,0xE0,0x10,0x08,0x08,0x10,0xE0,0x00,0x00,0x00,0x31,0x22,0x22,0x11,0x0F,0x00,//9
          0x00,0x00,0xC0,0x38,0xE0,0x00,0x00,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,//A 1
          0x08,0xF8,0x88,0x88,0x88,0x70,0x00,0x00,0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,//B 2
          0xC0,0x30,0x08,0x08,0x08,0x08,0x38,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,//C 3
          0x08,0xF8,0x08,0x08,0x08,0x10,0xE0,0x00,0x20,0x3F,0x20,0x20,0x20,0x10,0x0F,0x00,//D 4
          0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x20,0x23,0x20,0x18,0x00,//E 5
          0x08,0xF8,0x88,0x88,0xE8,0x08,0x10,0x00,0x20,0x3F,0x20,0x00,0x03,0x00,0x00,0x00,//F 6
          0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,//a 27
          0x08,0xF8,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,//b 28
          0x00,0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,//c 29
          0x00,0x00,0x00,0x80,0x80,0x88,0xF8,0x00,0x00,0x0E,0x11,0x20,0x20,0x10,0x3F,0x20,//d 30
          0x00,0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x22,0x13,0x00,//e 31
          0x00,0x80,0x80,0xF0,0x88,0x88,0x88,0x18,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00//f 32
          };

          void delay(uint ms)
          {
          uchar j;
          while(ms--)
          for(j=0;j=20;j++); //20us=0.02ms//

          }

          /////////////////////////Serial///////////////////////////

          void WrateC(uchar com)

          {
          unsigned char data i,j;
          C_S=0;
          R_S=0;
          SCK=0;
          for(i=0;i<8;i++)
          {
          j=com;
          SCK=0;
          SDA=com&0x80;
          SCK=1;
          com=j<<1;
          }
          C_S=1;
          R_S=1;
          }

          void WrateD(uchar dat)
          {
          unsigned char data i,j;
          C_S=0;
          R_S=1;
          SCK=0;
          for(i=0;i<8;i++)
          {
          j=dat;
          SCK=0;
          SDA=dat&0x80;
          SCK=1;
          dat=j<<1;
          }
          C_S=1;
          R_S=0;
          }

          void ClearDisplay()
          {
          unsigned chari,j;
          for(i=0;i<8;i++)
          {
          WrateC(Page+i);// (Page = 0xB0)//設(shè)置位置
          WrateC(0x10);
          WrateC(0x00);
          for(j=0;j<132;j++)//發(fā)送數(shù)據(jù)
          {
          WrateD(0);
          }
          }
          }
          void LcdInit()
          {
          RES=0;
          delay(50);//最少2um
          RES=1;
          delay(20);

          WrateC(0xe2);//軟件復(fù)位
          WrateC(0xA3);//Bais set顯示偏壓
          WrateC(0xA1);//ADC seg鏡像選擇 0xa0正常,0xA1左右鏡像
          WrateC(0xc0);//com output scan direction,com鏡像選擇 0xc0正常,0xC8上下鏡像
          /////////Select internal resistor ratio/////////
          WrateC(0x2c);//內(nèi)部電源管理
          WrateC(0x2e);//三條指令間隔時間2um
          WrateC(0x2F);//
          //////////////////////////////////////////////////////////////////////////////

          WrateC(0x81);//電壓模式選擇
          WrateC(0x16);//電壓調(diào)整寄存器低位 范圍:0x00-0x3f
          WrateC(0x24);//電壓調(diào)整寄存器高位 范圍:0x21-0x27 ,值越大,顯示效果越濃(底影越濃)

          WrateC(0xAF);//顯示開
          WrateC(0x40);//從首行開始顯示

          ClearDisplay();
          }

          void Setadd(uchar xl,uchar yl)
          {uchar i;
          i=xl&0x0f;
          xl=(xl>>4)+0x10;

          WrateC(0xb0+yl);
          WrateC(xl);
          WrateC(i);
          }

          void ShowOneDig(uchar col,uchar pag,uchar d)
          {
          uchar i = 0 ;
          uchar j;
          if(col>0x7f)
          {
          col=0;
          pag+=2;
          }
          Setadd(col,pag);
          for(j=0;j<8;j++)
          {
          WrateD(Number[d][i++]);
          }
          pag++;
          Setadd(col,pag);
          for(j=0;j<8;j++)
          {
          WrateD(Number[d][i++]);
          }
          pag++;
          }

          void main()
          {
          unsigned char a = 0 ;
          LcdInit();
          ClearDisplay();
          ShowOneDig(80,3,10);
          ShowOneDig(88,3,9);
          ShowOneDig(72,3,5);
          while(1);
          }


          關(guān)鍵詞: 51單片機ST7565驅(qū)動程

          評論


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

          關(guān)閉