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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 6349|回復: 3
打印 上一主題 下一主題
收起左側

兩個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)


評分

參與人數 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎勵!

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復

使用道具 舉報

沙發
ID:540924 發表于 2019-5-18 11:27 | 只看該作者
老哥你的圖打不開啊,能不能發個完整的接線截圖啊
回復

使用道具 舉報

板凳
ID:540924 發表于 2019-5-18 12:55 | 只看該作者
請問可以看一下兩片74hc595驅動的八位數碼館proteus仿真圖嗎,你發的資料里面的圖打不開
回復

使用道具 舉報

地板
ID:673209 發表于 2019-12-26 09:39 | 只看該作者
代碼不完整
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表