我这里有什么问题吗
#include <REGX52.H>#include "Timer0.h"
#include "Key.h"
#include "Delay.h"
#include "Nixie.h"
unsigned char KeyNum;
unsigned char Temp;
void main ()
{
Timer0_Init();
while (1)
{
KeyNum=Key();
}
}
void Timer0_Routine() interrupt 1
{
static unsigned int T0Count1,T0Count2;
void Key_Loop(void);
TL0 = 0x66;
TH0 = 0xFC;
T0Count1++;
if(T0Count1>=20)
{
T0Count1=0;
Key_Loop();
}
T0Count2++;
if(T0Count2>=2)
{
T0Count2=0;
Nixie_Loop();
}
}
Build target 'Target 1'
compiling main.c...
main.c(7): error C132: 'KeyNum': not in formal parameter list
main.c(8): error C132: 'Temp': not in formal parameter list
main.c(11): error C132: 'main': not in formal parameter list
main.c(11): error C141: syntax error near '{'
main.c(14): error C132: 'Timer0_Init': not in formal parameter list
main.c(14): error C141: syntax error near 'while'
main.c(16): error C244: 'KeyNum': can't initialize, bad type or class
main.c(16): error C132: 'KeyNum': not in formal parameter list
main.c(17): error C141: syntax error near '}'
Target not created.
Build Time Elapsed:00:00:00 这段代码中有多处错误:
缺少头文件,应该添加 #include <INTRINS.H> 头文件,否则会出现 "error C141: syntax error near '{'"的编译错误。
函数声明放在中括号外面,应该将其放在函数内部。
在main()函数中,调用了 Key() 函数,但是未定义此函数,需要确认是否存在此函数并正确包含相关的头文件。
定义变量时出现语法错误,需要删除初始化语句"=Key()",定义为 unsigned char KeyNum; unsigned char Temp;
Timer0_Init()函数未在此文件中声明或定义,需要检查是否正确包含相关的头文件。
函数结束符“}”要写在main函数后面,而不是Timer0_Routine()中。
以下是修改后的代码:
#include <REGX52.H>
#include <INTRINS.H>
#include "Timer0.h"
#include "Key.h"
#include "Delay.h"
#include "Nixie.h"
unsigned char KeyNum;
unsigned char Temp;
void main()
{
Timer0_Init();
while (1)
{
KeyNum = Key();
}
}
void Timer0_Routine() interrupt 1
{
static unsigned int T0Count1, T0Count2;
TL0 = 0x66;
TH0 = 0xFC;
T0Count1++;
if (T0Count1 >= 20)
{
T0Count1 = 0;
Key_Loop();
}
T0Count2++;
if (T0Count2 >= 2)
{
T0Count2 = 0;
Nixie_Loop();
}
}
void Key_Loop(void)
{
// TODO: 此函数的具体实现
}
页:
[1]