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

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 單片機(jī)SPI模塊+74LS164驅(qū)動數(shù)碼管

          單片機(jī)SPI模塊+74LS164驅(qū)動數(shù)碼管

          作者: 時間:2016-12-03 來源:網(wǎng)絡(luò) 收藏
          效果如下:循環(huán)右移再左移

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

          #include
          #ifndef _XTAL_FREQ
          #define _XTAL_FREQ 4000000
          #endif
          const unsigned char seg_comAnode[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,
          0x07,0x7f,0x6f};//共陽
          const unsigned char seg_comCathode[]={0xbf,0x86,0xdb,0xcf,0xe6,0xed,0xfd,
          0x87,0xff,0xef}; //共陰
          /*同時發(fā)送和接收一個字節(jié),74LS164吸電流大于拉電流,數(shù)碼管接成上拉形式*/
          unsigned char BUFF;
          void init(){
          TRISC=0B11010111;/*RC4/SDI引腳為輸出,RC5/SDO引腳為輸出,從模式RC3/SCK引腳為輸入*/
          SSPSTAT=0b00000000;/* 在結(jié)束時采樣,在上升沿?cái)?shù)據(jù)移位*/
          SSPCON=0b00110010;/* SSPEN=1;CKP=1 , FOSC/64,*/
          TRISD=0X00;
          PORTD=0;
          }
          void In_74LS164(unsigned char datas){
          SSPBUF=datas;
          do
          {
          ;
          }while(SSPIF==0);/*等待發(fā)送完畢*/
          SSPIF=0;/*清除SSPIF標(biāo)志*/
          //BUFF=SSPBUF;/*騰空緩沖器*/
          }
          void main()
          {unsigned char b,a,i,s=0;unsigned char m=0x01;
          init();
          while(1){

          for(i=0;i<4;i++)
          {
          PORTD=~(m<

          for(s=0;s<9;s++){

          In_74LS164( seg_comCathode[s]);
          __delay_ms(100);__delay_ms(100);
          }
          }

          for(i=1,a=m<<4;i<4;i++)
          {
          PORTD=~(a>>i);

          for(s=0;s<9;s++){

          In_74LS164( seg_comCathode[s]);
          __delay_ms(100);__delay_ms(100);
          }
          }
          }
          }



          評論


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