找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3629|回复: 0
收起左侧

icl7135单片机源程序

[复制链接]
ID:104835 发表于 2016-2-3 21:11 | 显示全部楼层 |阅读模式
下面是我编的读icl7135的源程序,是串行接法,晶振6M,icl7135是种频是从单片机ALE端引出后四分之一分频得到的频率.
  1. #include<reg52.h>
  2. #include<math.h>
  3. #define uchar unsigned char
  4. #define unit unsigned int
  5. sbit p32=P3^2;
  6. uchar code dispbit[]={0xfe,0xfd,0xfb,0xf7,0xef}; // 定义位选
  7. uchar code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};//定义段码
  8. uchar dispbuf[5]={0,0,0,0,0,}; //显示缓冲
  9. uchar dispcount,t;
  10. unit x,y;
  11. bit flag;
  12. void main()
  13. {
  14. TMOD=0x9;
  15. TH0=0;
  16. TL0=0;
  17. TR0=1;
  18. ET0=1;
  19. IT0=1;
  20. EX0=1;
  21. EA=1;
  22. while(1)
  23. {
  24. x=y;
  25. dispbuf[4]=x/10000;
  26. x=x%10000;
  27. dispbuf[3]=x/1000;
  28. x=x%1000;
  29. dispbuf[2]=x/100;
  30. x=x%100;
  31. dispbuf[1]=x/10;
  32. x=x%10;
  33. dispbuf[0]=x;
  34. P0=dispcode[dispbuf[dispcount]];
  35. P2=dispbit[dispcount];
  36. dispcount++;
  37. if(dispcount==4)
  38. {
  39. dispcount=0;
  40. }
  41. for(t=0;t<50;t++);
  42. }
  43. }

  44. void int0(void) interrupt 0
  45. {
  46. if(flag==0)
  47. {
  48. flag=1;
  49. TH0=0;
  50. TL0=0;
  51. TR0=1;
  52. }
  53. else
  54. {
  55. flag=0;
  56. TR0=0;
  57. y=TH0*256+TL0;
  58. y=y-10001;
  59. TH0=0;
  60. TL0=0;
  61. }
  62. }
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表