keil错误:error c129: missing ';' before 'unsigned' 程序怎么修改还是编译不了,请各位前辈指点,谢谢
//中断控制实验程序#include<reg52.h>#include<intrins.h>unsignedcharcodeLEDData[]={0xC0,0xF9,0x...
//中断控制实验程序
#include <reg52.h >
#include <intrins.h>
unsigned char code LEDData[] =
{
0xC0,0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90, 0xff
};
//段码
unsigned char data display[3]; //显示缓存单元
unsigned char code scan_bit[8] =
{
0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f
};
//位码
unsigned char count; //计数单元
char code reserve[3]_at_ 0x3b; //保留0x3b开始的3个字节
/********************************************************
延时函数
********************************************************/
void delayms(unsigned int ms)
{
unsigned char k;
while (ms--)
{
for (k = 0; k < 114; k++)
;
}
}
/********************************************************
数据处理与显示函数
********************************************************/
void disp_count()
{
unsigned char n, temp;
temp = count;
for (n = 0; n <= 1; n++)
//数据处理
{
display[n] = temp % 10;
temp = temp / 10;
}
display[2] = temp; //百位数据
for (n = 2; n > 0; n--)
//高位为0,不显示
{
if (display[n] == 0)
display[n] = 0x0a;
else
break;
}
for (n = 0; n < 3; n++)
{
P0 = LEDData[display[n]]; //显示段码
P2 = scan_bit[n]; //输出位码
delayms(1);
P2 = 0xff; //关闭显示
}
}
void main(void)
{
P0 = 0xff;
P1 = 0xff;
P2 = 0xff;
IT0 = 0; //低电平触发
// IT0=1; //下降沿触发
IT1 = 0; //低电平触发
// IT1=1; //下降沿触发
EA = 1; //总中断允许
EX1 = 1; //开启INT1中断
EX0 = 1; //开启INT0中断
while (1)
{
disp_count(); //数码管显示
}
}
/********************************************************
INT0中断函数 (加计数)
********************************************************/
void INT0_ISR(void)interrupt 0
{
unsigned char x;
EX0 = 0; //关闭INT0中断
count++; //计数值加1
for (x = 0; x < 70; x++)
//用显示程序进行延时
{
disp_count();
}
EX0 = 1; //开启INT0中断
}
/********************************************************
INT1中断函数 (减计数)
********************************************************/
void INT1_ISR(void)interrupt 2
{
unsigned char x;
EX1 = 0; //关闭INT1中断
count--; //计数值减1
for (x = 0; x < 70; x++)
//用显示程序进行延时
{
disp_count();
}
EX1 = 1; //开启INT1中断
}
/********************************************************/
还是编译不了,如果我删掉那行语句,下面那行还是会出现同样的情况!
还补充点,具体是什么.h文件。 展开
#include <reg52.h >
#include <intrins.h>
unsigned char code LEDData[] =
{
0xC0,0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90, 0xff
};
//段码
unsigned char data display[3]; //显示缓存单元
unsigned char code scan_bit[8] =
{
0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f
};
//位码
unsigned char count; //计数单元
char code reserve[3]_at_ 0x3b; //保留0x3b开始的3个字节
/********************************************************
延时函数
********************************************************/
void delayms(unsigned int ms)
{
unsigned char k;
while (ms--)
{
for (k = 0; k < 114; k++)
;
}
}
/********************************************************
数据处理与显示函数
********************************************************/
void disp_count()
{
unsigned char n, temp;
temp = count;
for (n = 0; n <= 1; n++)
//数据处理
{
display[n] = temp % 10;
temp = temp / 10;
}
display[2] = temp; //百位数据
for (n = 2; n > 0; n--)
//高位为0,不显示
{
if (display[n] == 0)
display[n] = 0x0a;
else
break;
}
for (n = 0; n < 3; n++)
{
P0 = LEDData[display[n]]; //显示段码
P2 = scan_bit[n]; //输出位码
delayms(1);
P2 = 0xff; //关闭显示
}
}
void main(void)
{
P0 = 0xff;
P1 = 0xff;
P2 = 0xff;
IT0 = 0; //低电平触发
// IT0=1; //下降沿触发
IT1 = 0; //低电平触发
// IT1=1; //下降沿触发
EA = 1; //总中断允许
EX1 = 1; //开启INT1中断
EX0 = 1; //开启INT0中断
while (1)
{
disp_count(); //数码管显示
}
}
/********************************************************
INT0中断函数 (加计数)
********************************************************/
void INT0_ISR(void)interrupt 0
{
unsigned char x;
EX0 = 0; //关闭INT0中断
count++; //计数值加1
for (x = 0; x < 70; x++)
//用显示程序进行延时
{
disp_count();
}
EX0 = 1; //开启INT0中断
}
/********************************************************
INT1中断函数 (减计数)
********************************************************/
void INT1_ISR(void)interrupt 2
{
unsigned char x;
EX1 = 0; //关闭INT1中断
count--; //计数值减1
for (x = 0; x < 70; x++)
//用显示程序进行延时
{
disp_count();
}
EX1 = 1; //开启INT1中断
}
/********************************************************/
还是编译不了,如果我删掉那行语句,下面那行还是会出现同样的情况!
还补充点,具体是什么.h文件。 展开
4个回答
展开全部
我也试验了一下,复制到我的kiel 3中,编译之后没有错误和警告,我以前也遇到过类似问题,后来查出是.h文件中函数声明少了个分号,但你这个是编译器自带的头文件,只要你不动就应该没事.建议你到别的机器上拷贝你用的两个头文件,将原来的头文件覆盖,在编译试试.因为我和楼上的都编译成功了,只能怀疑你的头文件被改了.
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
大佬们看看这个呗
#define uchar unsigned char#define uint unsigned int#define out0 P0#define out2 P2#define out1 P1void delay(uint j){uchar i=250;for(;j>0;j--){while(--i);i=100;}}uchar code string[]={0x10,0x10,0xD0,0xFF,0x90,0x10,0x00,0x42,0xE2,0x52,0x4A,0xC6,0x42,0x40,0xC0,0x00,0x04,0x03,0x00,0xFF,0x00,0x23,0x10,0x8C,0x43,0x20,0x18,0x47,0x80,0x40,0x3F,0x00,0x00,0x82,0x82,0xBA,0xAA,0xAA,0xAA,0xAB,0xAA,0xAA,0xAA,0xBA,0x82,0x82,0x80,0x00,0x02,0x01,0xA0,0xAA,0xAA,0x56,0x56,0xAA,0xF2,0x12,0x2A,0x22,0x40,0x42,0x01,0x00,0x10,0x60,0x02,0x8C,0x00,0xFE,0x02,0xF2,0x52,0x5A,0x56,0x52,0x52,0xF2,0x02,0x00,0x04,0x04,0x7E,0x41,0x30,0x0F,0x20,0x13,0x49,0x81,0x7F,0x01,0x09,0x13,0x20,0x00,}void main(){uchar i,j,n;while(1){for(j=0;j<3;j++){for(n=0;n<40;n++){for(i=0;i<15;i++){out1=i%15;out0=string[i*2+j*32];out2=string[i*2+1+j*32];delay(4);out0=0xff;out2=0xff;}}}}}
#define uchar unsigned char#define uint unsigned int#define out0 P0#define out2 P2#define out1 P1void delay(uint j){uchar i=250;for(;j>0;j--){while(--i);i=100;}}uchar code string[]={0x10,0x10,0xD0,0xFF,0x90,0x10,0x00,0x42,0xE2,0x52,0x4A,0xC6,0x42,0x40,0xC0,0x00,0x04,0x03,0x00,0xFF,0x00,0x23,0x10,0x8C,0x43,0x20,0x18,0x47,0x80,0x40,0x3F,0x00,0x00,0x82,0x82,0xBA,0xAA,0xAA,0xAA,0xAB,0xAA,0xAA,0xAA,0xBA,0x82,0x82,0x80,0x00,0x02,0x01,0xA0,0xAA,0xAA,0x56,0x56,0xAA,0xF2,0x12,0x2A,0x22,0x40,0x42,0x01,0x00,0x10,0x60,0x02,0x8C,0x00,0xFE,0x02,0xF2,0x52,0x5A,0x56,0x52,0x52,0xF2,0x02,0x00,0x04,0x04,0x7E,0x41,0x30,0x0F,0x20,0x13,0x49,0x81,0x7F,0x01,0x09,0x13,0x20,0x00,}void main(){uchar i,j,n;while(1){for(j=0;j<3;j++){for(n=0;n<40;n++){for(i=0;i<15;i++){out1=i%15;out0=string[i*2+j*32];out2=string[i*2+1+j*32];delay(4);out0=0xff;out2=0xff;}}}}}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询