有没有帮一下小白的,实在看不出哪里错了
#define A P0
#include<intrins.h>
unsigned int c,flag;
void timer0() interrupt1;
void delay(unsigned int t);
void main()
{
char ls[]={0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
while(1)
{
char i;
for(i=0;i<9;i++)
{
A=ls[i];
delay(1000);
A=_cror_(A,1);
}
for(i=7;i>0;i--)
{
A=ls[i];
delay(1000);
A=_crol_(A,1);
}
}
}
void timer0() interrupt1
{
c--;
if(c==0)
flag=1;
}
void delay(unsigned int t)
{
TMOD=0x01;
TR0=1;
EA=1;
ET0=1;
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
c=t;
flag=0;
while(flag==0);
}
LED普通.C(8): error C132: 'main': not in formal parameter list
LED普通.C(8): error C141: syntax error near '{'
LED普通.C(9): error C244: 'ls': can't initialize, bad type or class
LED普通.C(9): error C132: 'ls': not in formal parameter list
LED普通.C(10): error C141: syntax error near 'while'
LED普通.C(10): error C141: syntax error near '1'
LED普通.C(13): error C141: syntax error near 'for'
LED普通.C(13): error C141: syntax error near '=', expected ')'
LED普通.C(13): error C129: missing ';' before '<'
Target not created
#include<reg51.h>
#define A P0
#include<intrins.h>
unsigned int c,flag;
// void timer0() interrupt 1;
void delay(unsigned int t);
void main()
{
char ls[]={0xff,0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
while(1)
{
char i;
for(i=0;i<9;i++)
{
A=ls[i];
delay(1000);
A=_cror_(A,1);
}
for(i=7;i>0;i--)
{
A=ls[i];
delay(1000);
A=_crol_(A,1);
}
}
}
void timer0() interrupt 1
{
c--;
if(c==0)
flag=1;
}
void delay(unsigned int t)
{
TMOD=0x01;
TR0=1;
EA=1;
ET0=1;
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
c=t;
flag=0;
while(flag==0);
}
终端函数不需要申明,include后面这里没看到,还有就是你有没有把这个c文件添加到工程
还是不行啊
Build target 'Target 1'
compiling 定时器延时.c...
定时器延时.C(32): error C132: 'interrupt1': not in formal parameter list
定时器延时.C(32): error C141: syntax error near '{'
定时器延时.C(33): error C132: 'c': not in formal parameter list
定时器延时.C(35): error C244: 'flag': can't initialize, bad type or class
定时器延时.C(35): error C132: 'flag': not in formal parameter list
定时器延时.C(36): error C141: syntax error near '}'
Target not created
错误:void timer0() interrupt1
正确:void timer0() interrupt 1
少了一个空格,中断服务程序不需要声明
对,我把声明去了,但还是不行,还是那些错误,这个c文件我添加进去了啊,怎么还是显示没有
是的是的,谢谢
原来是interrupt和1中间没有加空格,而且多声明了中断函数,感谢大家