在keil编译器中编译c程序,出现了 syntax error near";", 程序不复杂,想请教一下是哪错了。多谢。
#include <reg51.h> #include<stdio.h>
#include<string.h>
#define uchar unsigned char
#define uint unsigned int
sbit YinYue=P1^6;
void delay(void);
uchar keyscan();
void timer0_int(void) interrupt 1;// 定时器0中断服务程序 // 就是这个地方
void timer1_int(void) interrupt 3; //定时器3中断服务程序 // 就是这个地方
uchar getcode(uchar i); //根据共阴极字型编码表获取字型代码
void display( ); //显示函数
bit pwcmp(void); //密码比较函数
uchar digbit; //字位
uchar wordbuf[6]; //字型码缓冲区
uchar tlcount; //定时器1由50ms积累到1s所用的计数器
uchar count; //密码位计数
uchar pw[6]; //初始密码存储区
uchar pwbuf[6]; //输入密码存储区
bit enterflag; //确认键按下与否标志
bit pwflag; //密码正确与否标志
bit showflag; //数码管显示与否标志
sbit green=P1^7;
sbit red=P2^4;
//应用程序主函数
void main(void)
{
uchar j,key;
P2=0x0;
TMOD=0x11;
//2ms定时设置
TH0=-2000/256;
TL0=-2000%256;
//50ms定时设置
TH0=-50000/256;
TL0=-20000%256;
//启动计数器0,关闭计数器1
TR0=1;
ET0=1;
TR1=0;
ET1=1;
EA=1;
count=0;
enterflag=0;
pwflag=0;
green=1;
red=1;
//假设内定密码为304222
pw[0]=3;
pw[1]=0;
pw[2]=4;
pw[3]=2;
pw[4]=2;
pw[5]=2;
showflag=1; //打开数码管显示
for(j=0;j<6;j++)
wordbuf[j]=8;
digbit=0x01;
while(1)
{
key=keyscan();
switch(key)
{
case 0x11:
if(count<6)
{
wordbuf[count]=0x0f;
pwbuf[count]=0;
count++;
}
break;
case 0x21:
if(count<6)
{
wordbuf[count]=0x0f;
pwbuf[count]=1;
count++;
}
break;
case 0x41:
if(count<6)
{
wordbuf[count]=0x0f;
pwbuf[count]=2;
count++;
}
break;
case 0x81:
if(count<6)
{
wordbuf[count]=0x0f;
pwbuf[count]=3;
count++;
}
break;
case 0x12:
if(count<6)
{
wordbuf[count]=0x0f;
pwbuf[count]=4;
count++;
}
break;
case 0x22:
if(count<6)
{
wordbuf[count]=0x0f;
pwbuf[count]=5;
count++;
}
break;
case 0x42:
if(count<6)
{
wordbuf[count]=0x0f;
pwbuf[count]=6;
count++;
}
break;
case 0x82:
if(count<6)
{
wordbuf[count]=0x0f;
pwbuf[count]=7;
count++;
}
break;
case 0x14:
if(count<6)
{
wordbuf[count]=0x0f;
pwbuf[count]=8;
count++;
}
break;
case 0x24:
if(count<6)
{
wordbuf[count]=0x0f;
pwbuf[count]=9;
count++;
}
break;
case 0x44:
enterflag=1;
if(count<6)
pwflag=pwcmp();
else
pwflag=0;
break;
case 0x84:
count=0;
for(j=0;j<6;j++)
{
wordbuf[j]=8;
pwbuf[j]=0x0f;
}
break;
default:break;
}
if(enterflag==1)
{
enterflag=0;
count=0;
//用FFFF清除已经输入的密码
for(j=0;j<6;j++)
pwbuf[j]=0x0f;
showflag=0;//关闭数码管显示
TR1=1;
tlcount=0;
if(pwflag==1)
green=0;
else
red=0;
}
}
}
//按键消抖延时函数
void delay(void)
{
uchar i;
for(i=300;i>0;i--);
}
//按键扫描函数
uchar keyscan(void)
{
uchar scancode,tmpcode;
P1=0xf0;
if((P1&0xf0)!=0xf0)
{
delay();
if((P1&0xf0)!=0xf0)
{
scancode=0xfe;
while((scancode&0x01)!=0)//逐行扫描
{
P1=scancode;
if((P1&0xf0)!=0xf0)
{
tmpcode=(P1&0xf0)|0xf0; //返回特征字节码,为1的位即对应于行和列
return((~scancode)+(~tmpcode));
}
else
scancode=(scancode<<1)|0x01;//行扫描码左移一位
}
}
}
return(0);//无键按下,返回值为0
}
//定时器0中断服务子程序,2ms定时动态扫描显示
void timer0_int(void) interrupt 1
{
//重置2ms定时
TH0=-2000/256;
TL0=-2000&256;
if(showflag==1)
display();
}
//定时器1中断服务子程序,50ms定时动态扫描显示
void timer1_int(void) interrupt 3
{
uchar k;
//重置50ms定时
TH0=-50000/256;
TL0=-50000&256;
if(tlcount<20)
{
tlcount++;
}
else
{
TR1=0;
tlcount=0;
green=1;
red=1;
showflag=1;
digbit=0x01;
for(k=0;k<6;k++)
wordbuf[k]=8;
}
}
//根据 共阴极编码表获取0~9,A~B字形代码
uchar getcode(uchar i)
{
uchar p;
switch(i)
{
case 0: p=0x3f; break;//0
case 1: p=0x06; break;//1
case 2: p=0x5B; break;//2
case 3: p=0x4f; break;//3
case 4: p=0x66; break;//4
case 5: p=0x6D; break;//5
case 6: p=0x7D; break;//6
case 7: p=0x07; break;//7
case 8: p=0x7F; break;//8
case 9: p=0x67; break;//9
case 9: p=0x67; break;//9
case 10: p=0x77; break;//A
case 11: p=0x7C; break;//B
case 12: p=0x39; break;//C
case 13: p=0x5E; break;//D
case 14: p=0x79; break;//E
case 15: p=0x67; break;//F
default: break;
}
return(p);
}
//数码管显示函数
void display(void)
{
uchar i;
switch(digbit)
{
case 1: i=0;break;
case 1: i=0;break;
case 1: i=0;break;
case 1: i=0;break;
case 1: i=0;break;
case 1: i=0;break;
case 1: i=0;break;
}
P2=0x0;
P0=getcode(wordbuf[i]);
P2=digbit;
if(digbit<0x20)
digbit=digbit<<1;
else
digbit=0x01;
}
//密码比较函数
bit pwcmp(void)
{
bit flag;
uchar i;
for(i=0;i<6;i++)
{
if(pw[i]==pwbuf[i])
flag=1;
else
{
flag=0;
i=6;
}
}
return(flag);
}