找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 648|回复: 0
打印 上一主题 下一主题
收起左侧

求用at89c51单片机测LM331 V/F转化后的频率 我的没有显示

[复制链接]
跳转到指定楼层
#
100黑币
我的没有显示,帮一下,谢谢。
要仿真图和程序
   


  1. #include <reg51.h>
  2. sbit Awei = P1^0;
  3. sbit Bwei = P1^1;
  4. sbit Cwei = P1^2;
  5. sbit Dwei = P1^3;

  6. void jisuan();
  7. void delay(int x);
  8. int change(int x);


  9. #define SHU_0 0X3F;
  10. #define SHU_1 0X06;
  11. #define SHU_2 0X5B;
  12. #define SHU_3 0X4F;
  13. #define SHU_4 0X66;
  14. #define SHU_5 0X6D;
  15. #define SHU_6 0X7D;
  16. #define SHU_7 0X07;
  17. #define SHU_8 0X7F;
  18. #define SHU_9 0X6F;

  19. int ge=0, shi=0, bai=0, qian=0;
  20. int count = 0, i = 0;
  21. int freq = 0;
  22. int main()
  23. {
  24. ge = 0; shi = 0; bai = 0; qian = 0;

  25. TMOD = 0X15;

  26. TH0 = 0;
  27. TL0 = 0;
  28. TH1 = (65535 - 50000)/256;
  29. TL1 = (65535 - 50000)%256;

  30. IT0 = 1;
  31. EX0 = 1;

  32. EA = 1;
  33. ET0 = 1;
  34. ET1 = 1;

  35. TR0 = 1;
  36. TR1 = 1;
  37. while(1)
  38. {

  39. jisuan();
  40. Awei = 1; Bwei = 1; Cwei = 1; Dwei = 0;
  41. P2 = change(ge);
  42. delay(10);
  43. P2 = 0X00;
  44. Awei = 1; Bwei = 1; Cwei = 0; Dwei = 1;
  45. P2 = change(shi);
  46. delay(10);
  47. P2 = 0X00;
  48. Awei = 1; Bwei = 0; Cwei = 1; Dwei = 1;
  49. P2 = change(bai);
  50. delay(10);
  51. P2 = 0X00;
  52. Awei = 0; Bwei = 1; Cwei = 1; Dwei = 1;
  53. P2 = change(qian);
  54. delay(10);
  55. P2 = 0X00;
  56. }
  57. }
  58. void service_timer0() interrupt 1 using 1
  59. {
  60. TH0 = 0;
  61. TL0 = 0;
  62. }
  63. void service_timer1() interrupt 3 using 3
  64. {
  65. TH1 = (65535 - 50000)/256;
  66. TL1 = (65535 - 50000)%256;
  67. i++;
  68. if (i == 20)
  69. {
  70. freq =TL0 + TH0*256;
  71. i = 0;
  72. TH0 = 0;
  73. TL0 = 0;
  74. }
  75. }

  76. void jisuan()
  77. {
  78. qian = freq /1000;
  79. bai = (freq%1000)/100;
  80. shi = (freq%100)/10;
  81. ge = freq%10;
  82. }
  83. void delay(int x)
  84. {
  85. int i, j;
  86. for(i = 0; i < x; i++)
  87. for(j = 0; j < 100; j++);
  88. }
  89. int change(int x)
  90. {
  91. int shu;
  92. switch(x)
  93. {
  94. case 0: shu = SHU_0; break;
  95. case 1: shu = SHU_1; break;
  96. case 2: shu = SHU_2; break;
  97. case 3: shu = SHU_3; break;
  98. case 4: shu = SHU_4; break;
  99. case 5: shu = SHU_5; break;
  100. case 6: shu = SHU_6; break;
  101. case 7: shu = SHU_7; break;
  102. case 8: shu = SHU_8; break;
  103. case 9: shu = SHU_9; break;
  104. }
  105. return shu;
  106. }
复制代码

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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