找回密码
 立即注册

QQ登录

只需一步,快速开始

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

protues仿真出现“no end statement found”,怎么办?

[复制链接]
ID:316737 发表于 2018-5-10 11:34 | 显示全部楼层 |阅读模式
QQ截图20180510113209.png
报错:no end statement found

源码如下:
  1. TMOD=0x51;
  2. TH0=0xD8;
  3. TL0=0xF0;
  4. ET0=1;
  5. EA=1;
  6. TR0=1;
  7. }
  8. void init_timer1()
  9. {
  10. TMOD=0x51;
  11. TH1=0x00;
  12. TL1=0x00;
  13. ET1=1;
  14. EA=1;
  15. TR1=1;
  16. }
  17. void it_timer0() interrupt 1
  18. {
  19. uchar counter;
  20. TF0=0;
  21. TH0=0xD8;
  22. TL0=0xF0;
  23. counter++;
  24. if(counter==100)
  25. {
  26. speed=(TH1*256+TL1+65536*cnt_ovtime)/100;
  27. if(speed>=1200)
  28. {
  29. exc_speed=1;
  30. nor_speed=0;
  31. }
  32. else
  33. {
  34. nor_speed=1;
  35. exc_speed=0;
  36. }
  37. TH1=TL1=0x00;
  38. counter=0;
  39. cnt_ovtime=0;
  40. }
  41. }
  42. void it_timer1()interrupt 3
  43. {
  44. TF1=0;
  45. cnt_ovtime++;
  46. }
  47. void WriteDataLcd(uchar wdata)
  48. {
  49. LCD_DATA=wdata;
  50. LCD_RS=1;
  51. LCD_RW=0;
  52. LCD_E=0;
  53. dellay(100);
  54. LCD_E=1;
  55. }
  56. void WriteCommandLcd(uchar wdata)
  57. {
  58. LCD_DATA=wdata;
  59. LCD_RS=0;
  60. LCD_RW=0;
  61. LCD_E=0;
  62. dellay(100);
  63. LCD_E=1;
  64. }
  65. void lcd_init(void)
  66. {
  67. LCD_DATA=0;
  68. WriteCommandLcd(0x38);
  69. dellay(1000);
  70. WriteCommandLcd(0x38);
  71. WriteCommandLcd(0x08);
  72. WriteCommandLcd(0x01);
  73. WriteCommandLcd(0x06);
  74. WriteCommandLcd(0x0c);
  75. }
  76. void display_xy(uchar x,uchar y)
  77. {
  78. if(y==1)
  79. x+=0x40;
  80. x+=0x80;
  81. WriteCommandLcd(x);
  82. }
  83. void display_char(uchar x,uchar y,uchar dat)
  84. {
  85. display_xy(x,y);
  86. WriteDataLcd(dat);
  87. }
  88. void display_string(uchar x,uchar y,uchar *s)
  89. {
  90. display_xy(x,y);
  91. while(*s)
  92. {
  93. WriteDataLcd(*s);
  94. s++;
  95. }
  96. }
  97. void main()
  98. {
  99. lcd_init();
  100. init_timer0();
  101. init_timer1();
  102. if(test)
  103. {
  104. P3 |=0x07;
  105. display_string(0,0,"Life is precious!");
  106. display_string(0,1,"Safe Driving!");
  107. delay_ms(2000);
  108. P3 &=~0x07;
  109. lcd_init();
  110. test=0;
  111. normal=1;
  112. delay_ms(2000);
  113. }
  114. if(normal)
  115. {
  116. while(1)
  117. {
  118. if(nor_speed)
  119. {
  120. P3 |=0x01;
  121. P3 &=~0x06;
  122. display_string(0,0,"Speed:");
  123. dis[3]=speed/1000;
  124. dis[4]=speed%1000;
  125. dis[2]=dis[4]/100;
  126. dis[4]=dis[4]%100;
  127. dis[1]=dis[4]/10;
  128. dis[0]=dis[4]%10;
  129. if(dis[3]!=0)
  130. {
  131. display_char(6,0,dis[3]+0x30);
  132. }
  133. else
  134. {
  135. display_char(6,0,0xA0);
  136. }
  137. display_char(7,0,dis[2]+0x30);
  138. display_char(8,0,dis[1]+0x30);
  139. display_char(10,0,dis[0]+0x30);
  140. display_string(9,0,".");
  141. display_string(11,0,"km/h");
  142. display_string(0,1,"Status:Normal");
  143. }
  144. if(exc_speed)
  145. {
  146. display_string(0,0,"Speed:");
  147. dis[3]=speed/1000;
  148. dis[4]=speed%1000;
  149. dis[2]=dis[4]/100;
  150. dis[4]=dis[4]%100;
  151. dis[1]=dis[4]/10;
  152. dis[0]=dis[4]%10;
  153. if(dis[3]!=0)
  154. {
  155. display_char(6,0,dis[3]+0x30);
  156. }
  157. else
  158. {
  159. display_char(6,0,0xA0);
  160. }
  161. display_char(7,0,dis[2]+0x30);
  162. display_char(8,0,dis[1]+0x30);
  163. display_char(10,0,dis[0]+0x30);
  164. display_string(9,0,".");
  165. display_string(11,0,"km/h");
  166. display_string(0,1,"Status:Speeding!");
  167. P3 &=~0x01;
  168. P3 |=0x06;
  169. delay_ms(500);
  170. display_string(0,1,"Warning!");
  171. P3 &=~0x06;
  172. delay_ms(500);
  173. }
  174. }
  175. }
  176. }
复制代码






回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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