各位高手 江湖救急!
#include<stdlib.h>//包含随机函数rand()
unsigned int x;
unsigned char i;
unsigned char code Tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
//......delay....
//......
void delay(void)
{
unsigned int j;
for(j=0;j<300;j++);
}
//display......
//....
void display(unsigned int k)
{
P2=0x01;
P1=Tab[k/1000];
delay();
P2=0x02;
P1=Tab[(k%1000)/100];
delay();
P2=0x04;
P1=Tab[((k%1000)%100)/10];
delay();
P2=0x08;
P1=Tab[((k%1000)%100)%10];
delay();
P2=0;//turn off all
}
//.....main.....
//.
void main(void)
{
TMOD=0x01;//choise 工作模式
TH0=(65536-46083)/256;
TL0=(65536-46083)%256;//赋初值
EA=1;
ET0=1;
TR0=1;
i=0;
while(1)
{
display(x);
}
}
//interrupt....
//......
void Time0(void) interrupt1 using 1
{
TR0=0;
i++;
if(i==20)
{
x=rand()/10;
i=0;
}
TH0=(65536-46083)/256;
TL0=(65536-46083)%256;//赋初值
TR0=1;
}
。。。
。。。
Build target 'Target 1'
compiling chap1.c...
..\用LED数码显示器循环显示数字0-9\CHAP1.C(26): error C100: unprintable character 0xA3 skipped
..\用LED数码显示器循环显示数字0-9\CHAP1.C(26): error C100: unprintable character 0xA8 skipped
..\用LED数码显示器循环显示数字0-9\CHAP1.C(26): error C141: syntax error near ')'
..\用LED数码显示器循环显示数字0-9\CHAP1.C(26): error C141: syntax error near ']'
..\用LED数码显示器循环显示数字0-9\CHAP1.C(64): error C132: 'interrupt1': not in formal parameter list
..\用LED数码显示器循环显示数字0-9\CHAP1.C(64): error C141: syntax error near 'using'
..\用LED数码显示器循环显示数字0-9\CHAP1.C(67): error C244: 'TR0': can't initialize, bad type or class
..\用LED数码显示器循环显示数字0-9\CHAP1.C(67): error C132: 'TR0': not in formal parameter list
..\用LED数码显示器循环显示数字0-9\CHAP1.C(68): error C132: 'i': not in formal parameter list
..\用LED数码显示器循环显示数字0-9\CHAP1.C(68): error C141: syntax error near '++'
..\用LED数码显示器循环显示数字0-9\CHAP1.C(71): error C244: 'x': can't initialize, bad type or class
..\用LED数码显示器循环显示数字0-9\CHAP1.C(71): error C132: 'x': not in formal parameter list
..\用LED数码显示器循环显示数字0-9\CHAP1.C(73): error C244: 'i': can't initialize, bad type or class
..\用LED数码显示器循环显示数字0-9\CHAP1.C(73): error C132: 'i': not in formal parameter list
..\用LED数码显示器循环显示数字0-9\CHAP1.C(74): error C141: syntax error near '}'
..\用LED数码显示器循环显示数字0-9\CHAP1.C(80): error C141: syntax error near '}'
。。。。。
这是什么情况
(初学 单片机)
#include<reg51.h>
#include<stdlib.h>//包含随机函数rand()
unsigned int x;
unsigned char i;
unsigned char code Tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
//......delay....
//......
void delay(void)
{
unsigned int j;
for(j=0;j<300;j++);
}
//display......
//....
void display(unsigned int k)
{
P2=0x01;
P1=Tab[k/1000];
delay();
P2=0x02;
P1=Tab[(k%1000)/100];
delay();
P2=0x04;
P1=Tab[((k%1000)%100)/10];
delay();
P2=0x08;
P1=Tab[((k%1000)%100)%10];
delay();
P2=0;//turn off all
}
//.....main.....
//.
void main(void)
{
TMOD=0x01;//choise 工作模式
TH0=(65536-46083)/256;
TL0=(65536-46083)%256;//赋初值
EA=1;
ET0=1;
TR0=1;
i=0;
while(1)
{
display(x);
}
}
//interrupt....
//......
void Time0(void) interrupt 1 using 1
{
TR0=0;
i++;
if(i==20)
{
x=rand()/10;
i=0;
}
TH0=(65536-46083)/256;
TL0=(65536-46083)%256;//赋初值
TR0=1;
}
void Time0(void) interrupt1 using 1改成
void Time0(void) interrupt 1 using 1
3Q 3q
