单片机程序错误
#include<reg52.h>#defineucharunsignedchar#defineuintunsignedintsbitled1=P1^0;ucharnum...
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit led1=P1^0;
uchar num;
void main()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
weile(1);
}
void T0_time ()interrupt1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
num++;
if(num==20)
{
num=0;
led1=-led1;
}
}
提示出现十四个错误 纠结了
错误分别是
编译 main.c ...
MAIN.C(14): 警告 C206: 'weile': missing function-prototype
MAIN.C(14): 错误 C267: 'weile': requires ANSI-style prototype
MAIN.C(17): 错误 C132: 'interrupt1': not in formal parameter list
MAIN.C(17): 错误 C141: syntax error near '{'
MAIN.C(18): 错误 C244: 'TH0': can't initialize, bad type or class
MAIN.C(18): 错误 C132: 'TH0': not in formal parameter list
MAIN.C(19): 错误 C244: 'TL0': can't initialize, bad type or class
MAIN.C(19): 错误 C132: 'TL0': not in formal parameter list
MAIN.C(20): 错误 C132: 'num': not in formal parameter list
MAIN.C(20): 错误 C141: syntax error near '++'
MAIN.C(23): 错误 C244: 'num': can't initialize, bad type or class
MAIN.C(23): 错误 C132: 'num': not in formal parameter list
MAIN.C(24): 错误 C244: 'led1': can't initialize, bad type or class
MAIN.C(24): 错误 C132: 'led1': not in formal parameter list
MAIN.C(25): 错误 C141: syntax error near '}'
main.c - 14 个错误, 1 个警告。
求大神解释 指教 展开
#define uchar unsigned char
#define uint unsigned int
sbit led1=P1^0;
uchar num;
void main()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
weile(1);
}
void T0_time ()interrupt1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
num++;
if(num==20)
{
num=0;
led1=-led1;
}
}
提示出现十四个错误 纠结了
错误分别是
编译 main.c ...
MAIN.C(14): 警告 C206: 'weile': missing function-prototype
MAIN.C(14): 错误 C267: 'weile': requires ANSI-style prototype
MAIN.C(17): 错误 C132: 'interrupt1': not in formal parameter list
MAIN.C(17): 错误 C141: syntax error near '{'
MAIN.C(18): 错误 C244: 'TH0': can't initialize, bad type or class
MAIN.C(18): 错误 C132: 'TH0': not in formal parameter list
MAIN.C(19): 错误 C244: 'TL0': can't initialize, bad type or class
MAIN.C(19): 错误 C132: 'TL0': not in formal parameter list
MAIN.C(20): 错误 C132: 'num': not in formal parameter list
MAIN.C(20): 错误 C141: syntax error near '++'
MAIN.C(23): 错误 C244: 'num': can't initialize, bad type or class
MAIN.C(23): 错误 C132: 'num': not in formal parameter list
MAIN.C(24): 错误 C244: 'led1': can't initialize, bad type or class
MAIN.C(24): 错误 C132: 'led1': not in formal parameter list
MAIN.C(25): 错误 C141: syntax error near '}'
main.c - 14 个错误, 1 个警告。
求大神解释 指教 展开
3个回答
展开全部
//复制过去试试
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit led1=P1^0;
uchar num;
void main()
{
num=0; //num给初始值
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
while(1); //while的正确写法
}
void T0_time () interrupt 1 //注意这里有空格
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
num++;
if(num==20)
{
num=0;
led1=~led1; //取反用“~”
}
}
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit led1=P1^0;
uchar num;
void main()
{
num=0; //num给初始值
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
while(1); //while的正确写法
}
void T0_time () interrupt 1 //注意这里有空格
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
num++;
if(num==20)
{
num=0;
led1=~led1; //取反用“~”
}
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
还有大括号、num没定初始值、
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
weile(1); while(1);
void T0_time()interrupt1 void T0_time() interrupt 1
led=-led; led=~led;
void T0_time()interrupt1 void T0_time() interrupt 1
led=-led; led=~led;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询