找回密码
 立即注册

QQ登录

只需一步,快速开始

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

keil c语言出现错误C206 missing function-prototype

[复制链接]
跳转到指定楼层
楼主
ID:732070 发表于 2020-4-20 13:00 来自手机 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

C206 missing function-prototype
  1. #include<reg52.h>
  2. #include<intrins.h>
  3. #define uchar unsigned char
  4. static unsigned char table[6]={0,0,0,0,0,0};
  5. //Declare functions
  6. uchar Busy_Check();
  7. void Initialize_LCD();
  8. void Write_LCD_Data(uchar dat);
  9. void Write_LCD_Command(uchar cmd);
  10. void Display_String(uchar x,uchar y,uchar *str);
  11. void Display_char(uchar hang,uchar lie,char sign);
  12. // void write_add(uchar address,uchar date);// 向 AT24Cxx 中的指定地址写入数据 uchar read_add(uchar address);// 从 AT24Cxx 中的指定地址读取数据
  13. void init();
  14. uchar h=20;
  15. sbit touch=P2^1;
  16. sbit touch1=P2^2;
  17. sbit speaker=P2^0;
  18. void delay(unsigned char ms) // 延时 **ms
  19. {
  20. unsigned char i;
  21. while(ms--)
  22. {
  23. for(i=250;i>0;i--)
  24. {
  25. _nop_();
  26. _nop_();
  27. _nop_();
  28. _nop_();
  29. }
  30. }
  31. }
  32. unsigned char keyscan() // 扫描键盘
  33. {
  34. unsigned char temp,y,j;
  35. unsigned char anjian[]={0xfe,0xfd,0xfb,0xf7};
  36. for(y=0;y<4;y++)
  37. {
  38. P1 = anjian[y];
  39. temp = 0x10;
  40. for(j=0;j<4;j++)
  41. {
  42. if(!(P1&temp))
  43. {
  44. return(j+y*4);
  45. }
  46. temp = _crol_(temp,1);
  47. }
  48. }
  49. }
  50. void judge()
  51. {
  52. P1 = 0xf0; if(P1!=0xf0) // 判断是否有按键
  53. {
  54. delay(50); delay(50); // 消抖
  55. if(P1!=0xf0)
  56. {
  57. h=keyscan();
  58. }
  59. }
  60. }
  61. void main()
  62. {
  63. unsigned char a=1,i=0,k=0,l=1,m=1,n,f=0,s=0;
  64. int q;
  65. Initialize_LCD();
  66. init();
  67. Display_String(1,1,"Welcome To Use ");
  68. Display_String(2,1," ");
  69. touch1=0; //第一个 while 循环
  70. while(1)
  71. {
  72. judge();
  73. if(h<10)
  74. {
  75. if(h==table[i])
  76. k++;
  77. Display_String(2,a,"*");
  78. a++;
  79. i++;
  80. if(a==7)
  81. a=1;
  82. if(i==6)
  83. i=0;
  84. h=16;
  85. }
  86. if(h==14)
  87. {
  88. Display_String(1,1,"Input Password");
  89. Display_String(2,1," ");
  90. h=16;
  91. touch=1;
  92. touch1=0;
  93. k=0;
  94. l=1;
  95. q=0;
  96. }
  97. if(h==12)
  98. {
  99. if(k==6)
  100. {
  101. Display_String(1,1,"Password Right");
  102. Display_String(2,1,"Lock Opened!");
  103. touch=~touch;
  104. }
  105. else
  106. {
  107. Display_String(1,1,"Password Error");
  108. Display_String(2,1," ");
  109. l=0;
  110. q++;
  111. while(q==3)
  112. {
  113. speaker=0;
  114. delay(200);
  115. delay(200);
  116. delay(200);
  117. speaker=1 ;
  118. q=0;
  119. }
  120. h=14;
  121. }
  122. delay(255);
  123. k=0;
  124. h=16;
  125. while(l)
  126. {
  127. judge();
  128. if(h==11)  
  129. { Display_String(1,1,"New Code");
  130. Display_String(2,1," ");
  131. while(m==1)
  132. {
  133. judge();
  134. touch1=~touch1;
  135. if(h<10)
  136. {
  137. table[n]=h;
  138. write_add(s,h);
  139. s++;
  140. Display_String(2,a,"*");
  141. a++;  
  142. n++;
  143. h=16;
  144. if(n==6)
  145. {
  146. n=0;
  147. s=0;
  148. }
  149. }
  150. if(h==15)
  151. {
  152. if(n==0)
  153. n=6;
  154. s=6;
  155. a--;
  156. s-- ;
  157. Display_String(2,a," ");
  158. n--;
  159. h=16;
  160. }
  161. if(h==13)
  162. m=0;
  163. }
  164. if(h==13)
  165. h=13;
  166. f=1;
  167. }
  168. if(h==14)
  169. {
  170. l=0;
  171. }
  172. if(h==13)
  173. {
  174. Display_String(2,1," ");
  175. for(n=0;n<6;n++)
  176. Display_char(2,n+1,(uchar)(table[n]+48) );h=13;l=0;f=1;}
  177. k=0;
  178. }
  179. }
  180. if(h==15)
  181. {
  182. a--;
  183. Display_String(2,a," ");
  184. k--;
  185. i--;
  186. h=16;
  187. }
  188. if(h==13)
  189. { if(f==1)
  190. { for(n=0;n<6;n++)
  191. Display_char(2,n+1,(uchar)(table[n]+48) );f=0; }
  192. else
  193. Display_String(2,1," ****** ");
  194. delay(255);
  195. delay(255);
  196. Display_String(1,1," Welcome To Use ");
  197. Display_String(2,1," ");
  198. l=1;a=1;k=0;n=0;m=1;
  199. h=16;
  200. }
  201. }
  202. for(s=0;s<6;s++)
  203. { table[s]=read_add(s);
  204. delay(50);
  205. }
  206. }
复制代码
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:94031 发表于 2020-4-20 16:09 | 只看该作者
错误太多,程序结构都有问题。
回复

使用道具 举报

板凳
ID:584814 发表于 2020-4-20 17:47 | 只看该作者
write_add()函数在第12行被注释掉了但在第138行被调用。
回复

使用道具 举报

地板
ID:753061 发表于 2020-6-7 07:15 来自手机 | 只看该作者
/********************引脚定义*********************/ #include "reg51.h" typedef unsigned int uint; typedef unsigned char uchar;  #define Duty_cycle 35 //占空间 #define Cycle 100 //PWM周期  sbit sensor_1 = P1^1; //红外检测 sbit sensor_2 = P1^1; sbit sensor_3 = P1^3;  sbit Motor_1H = P2^0; //电机驱动控制信号 sbit Motor_1L = P2^1; sbit Motor_2H = P2^2; sbit Motor_2L = P2^3;  sbit En_pwm1 = P2^4; //使能信号(RWM) sbit En_pwm2 = P2^5;  uchar timer1; //定义变量  /***************主函数*********************/ void mian( ) {  TimelConfig();//定时器初始化  while(1) {  if(Sensor_1==0 && Sensor_2==1 && Semsor_3==0) //状态:轨迹居中   Go_Straight(); //向前 else if(Sensor_1==0 && Sensor_2==0 && Semsor_3==1) //偏左   Turn_Right(); //右转 else if(Sensor_1==1 && Sensor_2==0 && Semsor_3==0) //偏右    Turn_left(); //左转 else if(Sensor_1==0 && Sensor_2==0 && Semsor_3==0) //偏离轨道   Go_Back(); //后退 else Go_Straight( ); //前进 } } /**************设置定时器***********/ void Time1Config() {   TMOD|= 0x10;   //设置定时计数器T1工作在模式1    /***定时器赋初始值, 12MHZ下定时0.5ms***/   TH1 = 0xFE;   TL1 = 0x0c;    ET1 = 1;    //开启定时器1中断   EA = 1;   TR1 = 1;    //开启定时器 } /********************定时器1的中断函数********************/ void Time1(void) interrupt 3    //3 为定时器1的中断号 {      timer1++;   if(timer1>Cyc1e)              //PWM周期为100*0.5ms     {       timer1=0;     }     if(timer1 < Duty_cyc1e)     //改变Duty_cyc1e这个值可以改变直流电机的速度     {       En_pwm1=1;       En_pwm2=1;     }     e1se     {       En_pwm1=0;       En_pwm2=0;     }   TH1 = 0xFE;                   //重新赋初值   TL1 = 0x0c; }
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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