请高人帮我看看51单片机写的关于数码显示时钟的C语言程序

#include<reg51.h>
#define uchar unsigned char;//宏定义
#define uint unsigned int;
sbit dula=P2^6; //段控制位
sbit wela=P2^7; //位控制位
uchar miao,fen,aa,n1,n2,n3,n4;
uchar code table[]={ //显示编码
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71}
void delay(uint); //延时程序声明
void init(); //初始化程序声明
void display(uchar n1 ,uchar n2,uchar n3,uchar n4); //显示程序声明

void main() //主程序
{
init(); //调用初始化程序
while(1) //进入大循环
{
if(aa==20) //判断是否到了1S
{
miao++; //秒数加1
if(miao==60) //判断是否到了60秒
{
miao=0; //秒数清0
fen++; //分数加1
if(fen==60) //判断是否到了60分
{
fen=0; //分数到60则清0
}

n1=fen/10; //第一个数码管显示分的十位
n2=fen%10; //第二个数码管显示分的个位
n3=miao/10; //第三个数码管显示秒的十位
n4=miao%10; //第四个数码管显示秒的个位
}
display(n1,n2,n3,n4)
}

}

void delay(uint z) //延时程序
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--)
}

void display(uchar n1,uchar n2,uchar n3,uchar n4)
{
dula=1; //开段选
P0=table[n1]; //送分的十位
dula=0; //关段选
P0=0xff; //消隐
wela=1; //开位选
P0=0xfe; //选通分的十位
wela=0; //关位选
P0=0xff; //消隐
delay(1) //延时

dula=1; //开段选
P0=table[n2]; //送分的个位
dula=0; //关段选
P0=0xff; //消隐
wela=1; //开位选
P0=0xfd; //选通分的个位
wela=0; //关位选
P0=0xff; //消隐
delay(1) //延时

dula=1; //开段选
P0=table[n3]; //送秒的十位
dula=0; //关段选
P0=0xff; //消隐
wela=1; //开位选
P0=0xfb; //选通秒的十位
wela=0; //关位选
P0=0xff; //消隐
delay(1) //延时

dula=1; //开段选
P0=table[n4]; //送秒的个位
dula=0; //关段选
P0=0xff; //消隐
wela=1; //开位选
P0=0xf7; //选通秒的个位
wela=0; //关位选
P0=0xff; //消隐
delay(1) //延时
}

void timer0 interrupt 1 //中断程序
{
TH0=(65536-50000)/256; //求模
TL0=(65536-50000)%256; //求余
aa++;

}
每次编译都说出错,但是我实在找不出来错误在哪里。请高人指教!
三楼的,我按照你说的加了几个分号。但是还是编译还是会出现
CESHI.C(12): error C141: syntax error near ';'
CESHI.C(13): error C100: unprintable character 0xA3 skipped
CESHI.C(13): error C100: unprintable character 0xA8 skipped
CESHI.C(13): error C100: unprintable character 0xA3 skipped
CESHI.C(13): error C100: unprintable character 0xA9 skipped
CESHI.C(13): error C136: 'init': 'void' on variable
CESHI.C(14): error C100: unprintable character 0xA3 skipped
CESHI.C(14): error C100: unprintable character 0xA8 skipped
CESHI.C(14): error C136: 'displayunsigned': 'void' on variable
CESHI.C(14): error C129: missing ';' before 'char'
Target not created

你所有调用display()和 delay()函数时候都没在后面加个分号。漏了还是???
还有:
uchar code table[]={ //显示编码
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71}
也应该在后面加个分号!!

你的分不好拿啊,该用分号的不用,不该用的地方用了,还有括号你用了很多中文的括号。
现在帮你改了,你自己好好对一下了,反正编译通过了,运行结果你自己看吧,我没你的目标板,运行不了。

#include<reg51.h>

#define uchar unsigned char//宏定义
#define uint unsigned int
sbit dula=P2^6; //段控制位
sbit wela=P2^7; //位控制位
uchar miao,fen,aa,n1,n2,n3,n4;
uchar code table[]={ //显示编码
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};

void delay(uint z); //延时程序声明
void init(void);//初始化程序声明
void display(uchar n1 ,uchar n2,uchar n3,uchar n4); //显示程序声明

void main() //主程序
{
init(); //调用初始化程序
while(1) //进入大循环
{
if(aa==20) //判断是否到了1S
{
miao++; //秒数加1
if(miao==60) //判断是否到了60秒
{
miao=0; //秒数清0
fen++; //分数加1
if(fen==60) //判断是否到了60分
{
fen=0; //分数到60则清0
}

n1=fen/10; //第一个数码管显示分的十位
n2=fen%10; //第二个数码管显示分的个位
n3=miao/10; //第三个数码管显示秒的十位
n4=miao%10; //第四个数码管显示秒的个位
}
display(n1,n2,n3,n4);
}

}
}

void delay(uint z) //延时程序
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}

void display(uchar n1 ,uchar n2,uchar n3,uchar n4)
{
dula=1; //开段选
P0=table[n1]; //送分的十位
dula=0; //关段选
P0=0xff; //消隐
wela=1; //开位选
P0=0xfe; //选通分的十位
wela=0; //关位选
P0=0xff; //消隐
delay(1); //延时

dula=1; //开段选
P0=table[n2]; //送分的个位
dula=0; //关段选
P0=0xff; //消隐
wela=1; //开位选
P0=0xfd; //选通分的个位
wela=0; //关位选
P0=0xff; //消隐
delay(1); //延时

dula=1; //开段选
P0=table[n3]; //送秒的十位
dula=0; //关段选
P0=0xff; //消隐
wela=1; //开位选
P0=0xfb; //选通秒的十位
wela=0; //关位选
P0=0xff; //消隐
delay(1); //延时

dula=1; //开段选
P0=table[n4]; //送秒的个位
dula=0; //关段选
P0=0xff; //消隐
wela=1; //开位选
P0=0xf7; //选通秒的个位
wela=0; //关位选
P0=0xff; //消隐
delay(1); //延时
}

void init(void)
{

}

void timer0(void) interrupt 1 using 1
{
TH0=(65536-50000)/256; //求模
TL0=(65536-50000)%256; //求余
aa++;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-07-22
init();
第2个回答  2008-07-22
编译器会有报告,告诉你错在哪的啊
相似回答