找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 5654|回复: 1
收起左侧

在proteus里运行报错 'TMOD': can't initialize, bad type or class

[复制链接]
ID:796820 发表于 2020-7-3 21:39 | 显示全部楼层 |阅读模式
  1. #include "regx51.h"
  2. unsigned char a,b,c,d;
  3. unsigned char code disaplay []= {0x3f, 0x06, 0x5b, 0x4f, 0x66,0x6d, 0x7d, 0x07, 0x7f, 0x6f} ;
  4. long counter=0; //旋转编码 器的脉冲
  5. long position=0; //旋转 编码器的当前位置
  6. long degree=0;
  7. void main()
  8. TMOD=0x06;
  9. TH0=0xff;
  10. TL0=0xff;
  11. TH1= (65536-1000)/256;
  12. TL1= (65536-1000)%256;
  13. IE=0x0f;
  14. EA = 1; //开总中断
  15. r=0;
  16. while(1)  //主程序循环显示位置
  17. {
  18. a=degree%10;  //计算参数的个十百千位
  19. b= (degree/10)%10; .
  20. c= (degree/100)%10;
  21. d= (degree/1000)%10;
  22. p2_3=0;//显示position值
  23. p0=diaplay[a];
  24. p2_3=1;
  25. p2_2=0;
  26. p0=diaplay[b];
  27. p2_ 2=1;
  28. p2_ 1=0;
  29. p0=diaplay[c];
  30. p2_1=1;
  31. p2_0=0;
  32. p0=diaplay[d];
  33. p2_0=1;
  34. }
  35. }
  36. void int0() interrupt 0   //A 相中断
  37. if(p2_7)position++;         //判断2_7 为高则正向,为低则反向
  38. else position;
  39. counte++ ;      //累计脉冲
  40. }
  41. void int1()
  42. interrupt 1   //Z相中断
  43. {
  44. position=0;   //使位置参数置零
  45. void tl_ () interrupt 2    //定时0. ls刷新一次转速和角
  46. //度参数
  47. THO= (65536-1000) /256;
  48. TL0= (65536-1000) %256;
  49. r=600*counter/ 300;   //假设编码器每转300个脉冲
  50. degree=1. 2*position; //把脉冲数转换为 角度数
  51. if(! degree)  //角度为负时加360度转为正
  52. degree+=360}
  53. void t0_ () interrupt 3  //计数器T0中断显示速度
  54. {
  55. unsigned char i
  56. i=100;
  57. a=r%10;
  58. b=(r/10)%10;
  59. c=(r/100)%10;
  60. d= (r/1000)%10;
  61. while(i)
  62. {
  63. p2_ 3=0;
  64. p0=diaplay[a];
  65. p2_ 3=1;
  66. p2_ 2=0;
  67. p0=diaplay[b];
  68. p2_ 2=1;
  69. p2_ 1=0;
  70. p0=diap1ay[c];
  71. p2_ 1=1;
  72. p2_ _0=0;
  73. p0=diaplay[d];
  74. p2_ 0=1;
  75. i-- ;
  76. }
  77. }
复制代码

*** WARNING C318 IN LINE 1 OF ..\main.c: can't open file 'regx51.h'
*** ERROR C244 IN LINE 8 OF ..\main.c: 'TMOD': can't initialize, bad type or class
*** ERROR C132 IN LINE 8 OF ..\main.c: 'TMOD': not in formal parameter list
回复

使用道具 举报

ID:452950 发表于 2020-7-3 22:47 | 显示全部楼层
regx51.h可能没有,改成
#include "reg51.h"应该就可以了
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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