教材上的键盘扫描程序错误一大堆啊(error C141: syntax error near '{')

[复制链接]
查看11 | 回复1 | 2009-4-23 10:01:53 | 显示全部楼层 |阅读模式
#include
#define uchar unsigned char
#define uint unsigned int
/*函数说明*/
void delay(void);
uchar keyscan();
/****键盘扫描****/
void keyscan(void);
{uchar row,col;
p1=0xf0;
if((p1&0xf0)!=0xf0) //判断有无按下
{delay();

if((p1&0xf0)!=0xf0) //再次判断

{ row=0xfe;
//p1.0置为0,开始行扫描

while((row&0x10)!=0xf0)
//用来判断是否为最后一行,若不是,继续扫描

{ p1=row;
//p1口输出行扫描值

if((p1&0xf0)!=0xf0)

{col=(p1&0xf0)|0x0f); //得到列

return((~row)+(~col));
//得出列(高四位)+行(低四位)

}

else

row=(row<<1)|0x01;
//移位用于判断在哪行

}

}
}


return 0;


}
/*延时函数*/
void delay(void)
{uchar i;
for(i=0;i<200;i++){}
}
/*******键盘扫描主函数*****/
void main(void)
{ uchar key;
uchar keyval;
while(1)
{key=keyscan();

delay();
}
}
//
出错提示:
Build target 'Target 1'
compiling jp.c...
JP.C(8): error C141: syntax error near '{'
JP.C(10): error C141: syntax error near 'if'
JP.C(10): error C141: syntax error near '&', expected ')'
JP.C(13): error C141: syntax error near 'if'
JP.C(13): error C141: syntax error near '&', expected ')'
JP.C(15): error C141: syntax error near 'while'
JP.C(15): error C141: syntax error near '&', expected ')'
JP.C(16): error C279: 'p1': multiple initialization
JP.C(16): error C247: non-address/-constant initializer
JP.C(17): error C141: syntax error near 'if'
JP.C(17): error C141: syntax error near '&', expected ')'
JP.C(18): error C247: non-address/-constant initializer
JP.C(18): error C141: syntax error near ')'
JP.C(22): error C279: 'row': multiple initialization
JP.C(22): error C247: non-address/-constant initializer
JP.C(23): error C141: syntax error near '}'
JP.C(27): error C141: syntax error near '0'
JP.C(32)(34): error C231: 'delay': redefinition
Target not created

回复

使用道具 举报

千问 | 2009-4-23 10:01:53 | 显示全部楼层
reg51.h这个头文件你有么???去拷一个基本就迎刃而解了...
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行