欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 兩個74HC595驅動8位數碼管程序+Proteus仿真 [打印本頁]

作者: freshone    時間: 2019-1-13 21:08
標題: 兩個74HC595驅動8位數碼管程序+Proteus仿真
兩個74HC595共用了,6 個IO  口,簡單的定時器 時鐘,主要 是74HC595的控制。仿真:


單片機源碼:(位定義在 源文件)
  1. #include<reg52.h>
  2. #include<intrins.h>
  3. typedef unsigned char uchar;
  4. typedef unsigned int uint;

  5. #define date P0
  6. #define count 50000
  7. #define TH_0 (65536-count)/256
  8. #define TL_0 (65536-count)%256


  9. uchar diss[8];
  10. uchar code distab[17] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,
  11.                                                                                                                                 0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71,0x40};
  12. uint sec=0,min=0,hour=0;

  13. void delay(uint iii)
  14. {
  15.         while(iii--);
  16. }
  17. void _74hc595_dula(uchar dat)
  18. {
  19.         uchar i=0;
  20.         sh_cp_dula=0;
  21.         st_cp_dula=0;
  22.         for(i=0;i<8;i++)
  23.         {
  24.                 dula=dat>>7;
  25.                 dat=dat<<1;
  26.                 sh_cp_dula=1;
  27.                 _nop_();
  28.                 _nop_();
  29.                 sh_cp_dula=0;
  30.         }
  31.         st_cp_dula=1;
  32.         _nop_();
  33.         _nop_();
  34.         st_cp_dula=0;
  35. }

  36. void _74hc595_wela(uchar dat)
  37. {
  38.         uchar i=0;
  39.         sh_cp_wela=0;
  40.         st_cp_wela=0;
  41.         for(i=0;i<8;i++)
  42.         {
  43.                 wela=dat>>7;
  44.                 dat=dat<<1;
  45.                 sh_cp_wela=1;
  46.                 _nop_();
  47.                 _nop_();
  48.                 sh_cp_wela=0;
  49.         }
  50.         st_cp_wela=1;
  51.         _nop_();
  52.         _nop_();
  53.         st_cp_wela=0;
  54. }

  55. void display()
  56. {
  57.         uchar dat,i=0;
  58.         for(dat=0xfe;dat!=0xff;dat=(dat<<1)|0x01)        //1011 1111   
  59.         {
  60.                 _74hc595_dula(distab[diss[i++]]);
  61.                
  62.                 _74hc595_wela(dat);
  63.                
  64.                 if(i==8)i=0;
  65.                
  66.                 delay(100);
  67.                 _74hc595_dula(0x00);
  68.                 delay(100);
  69.                
  70.         }
  71. }
  72. void disss()
  73. {
  74.         diss[0]=hour/10;
  75.         diss[1]=hour%10;
  76.         diss[2]=16;
  77.         diss[3]=min/10;
  78.         diss[4]=min%10;
  79.         diss[5]=16;
  80.         diss[6]=sec/10;
  81.         diss[7]=sec%10;
  82. }
  83. void timer0_init()
  84. {
  85.         TMOD=0x01;
  86.         EA=1;ET0=1;TR0=1;
  87.         TH0=TH_0;TL0=TL_0;
  88. }
  89. void main()
  90. {
  91.         timer0_init();
  92.         while(1)
  93.         {        
  94.                 display();
  95.                 disss();
  96.         }
  97. }
  98. void timer0() interrupt 1
  99. {
  100.         static uchar j;
  101.         TH0=TH_0;TL0=TL_0;
  102.         if(++j==20)
  103.         {
  104.                 j=0;
  105.                 sec++;
  106.                 if(sec==60)
  107.                 {
  108.                         sec=0;
  109.                         min++;
  110.                         if(min==60)
  111.                         {
  112.                                 min=0;
  113.                                 hour++;
  114.                                 if(hour==24)
  115.                                 {
  116.                                         hour=0;
  117.                                 }
  118.                         }
  119.                 }
  120.         }
  121. }
復制代碼
源文件: 74HC595數碼管.zip (118.53 KB, 下載次數: 162)



作者: 964088249    時間: 2019-5-18 11:27
老哥你的圖打不開啊,能不能發個完整的接線截圖啊
作者: 964088249    時間: 2019-5-18 12:55
請問可以看一下兩片74hc595驅動的八位數碼館proteus仿真圖嗎,你發的資料里面的圖打不開
作者: 4444iiu    時間: 2019-12-26 09:39
代碼不完整




歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1