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

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > AVR單片機(jī)IIC實(shí)驗(yàn)

          AVR單片機(jī)IIC實(shí)驗(yàn)

          作者: 時(shí)間:2016-11-30 來(lái)源:網(wǎng)絡(luò) 收藏

          //-------------------1602.h--------------------
          //------------1602.h-------------
          #define RS1 PORTB_Bit0=1
          #define RS0 PORTB_Bit0=0
          #define RW1 PORTB_Bit1=1
          #define RW0 PORTB_Bit1=0
          #define EN1 PORTB_Bit2=1
          #define EN0 PORTB_Bit2=0
          #define DATAPORT PORTA
          #define busy 0x80
          void wait()
          {
          uchar val;
          DATAPORT=0xff;
          RS0;
          RW1;
          __no_operation();
          EN1;
          __no_operation();
          __no_operation();
          DDRA=0x00;
          val=PINA;
          while(val&busy)val=PINA;
          EN0;
          DDRA=0xff;
          }

          void writecmd(uchar w)
          {
          wait();
          RS0;
          RW0;
          __no_operation();
          DATAPORT=w;
          __no_operation();
          EN1;
          __no_operation();
          __no_operation();
          EN0;
          }

          void writedata(uchar data)
          {
          wait();
          RS1;
          RW0;
          __no_operation();
          DATAPORT=data;
          __no_operation();
          EN1;
          __no_operation();
          __no_operation();
          EN0;
          }

          void delay_nms(uint k)
          {
          uint i,j;
          for(i=0;i
          for(j=0;j<1140;j++);
          }

          void init()
          {
          delay_nms(15);
          writecmd(0x38);
          delay_nms(5);
          writecmd(0x38);
          delay_nms(5);
          writecmd(0x38);
          writecmd(0x80);
          writecmd(0x01);
          writecmd(0x06);
          writecmd(0x0c);
          }

          void display(uchar x,uchar y,uchar *p)
          {

          uchar add=0x80;
          y=y&0x01;
          x=x&0x0f;
          if(y)add=add+0x40;
          writecmd(add+x);
          while(*p!=看屁屁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); })();