標(biāo)題: 四位顯示的頻率計(jì),帶proteus仿真 [打印本頁(yè)]

作者: tzrdcaabb    時(shí)間: 2018-11-7 22:14
標(biāo)題: 四位顯示的頻率計(jì),帶proteus仿真
四位顯示的頻率計(jì),帶proteus仿真

單片機(jī)源程序如下:
  1. #include <reg52.h>
  2. unsigned char code dispbit[]={0xef,0xdf,0xbf,0x7f};
  3. unsigned char code dispcode[]={0xc0,0Xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
  4. unsigned char dispbuf[4]={0,0,0,0};
  5. unsigned char temp[8];
  6. unsigned char dispcount;
  7. unsigned char T0count;
  8. unsigned char timecount;
  9. bit flag;
  10. unsigned long x;
  11. void main(void)
  12. {
  13. unsigned char i;
  14. TMOD=0x15;
  15. TH0=0;
  16. TL0=0;
  17. TH1=(65536-4000)/256;
  18. TL1=(65536-4000)%256;
  19. TR1=1;
  20. TR0=1;
  21. ET0=1;
  22. ET1=1;
  23. EA=1;
  24. while(1)
  25. {
  26. if(flag==1)
  27. {
  28. flag=0;
  29. x=T0count*65536+TH0*256+TL0;
  30. for(i=0;i<4;i++)
  31. {
  32. temp[i]=0;
  33. }
  34. i=0;
  35. while(x/10)
  36. {
  37. temp[i]=x%10;
  38. x=x/10;
  39. i++;
  40. }
  41. temp[i]=x;
  42. for(i=0;i<4;i++)
  43. {
  44. dispbuf[i]=temp[i];
  45. }
  46. timecount=0;
  47. T0count=0;
  48. TH0=0;
  49. TL0=0;
  50. TR0=1;
  51. }
  52. }
  53. }
  54. void t0(void) interrupt 1 using 0
  55. {
  56. T0count++;
  57. }
  58. void t1(void) interrupt 3 using 0
  59. {
  60. TH1=(65536-4000)/256;
  61. TL1=(65536-4000)%256;
  62. timecount++;
  63. if(timecount==250)
  64. {
  65. TR0=0;
  66. timecount=0;
  67. flag=1;
  68. }
  69. P0=dispcode[dispbuf[dispcount]];
  70. P2=dispbit[dispcount];
  71. dispcount++;
  72. if(dispcount==4)
  73. {
  74. dispcount=0;
  75. }
  76. }
復(fù)制代碼

所有資料51hei提供下載:
046、四位頻率計(jì).zip (101.26 KB, 下載次數(shù): 24)



作者: 158925    時(shí)間: 2018-12-12 18:03
你的仿真數(shù)碼管都不亮,真的是牛皮,騙人的帖子活該你沉了




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