帮忙看一下这个单片机程序错在哪里?总是编译错误。(答案正确的话会加分)
#include<reg51.h>#defineucharunsignedchar#defineuintunsignedintsbitRED_A=P0^0;sbitYEL...
#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
sbit RED_A= P0^0;
sbit YELLOW_A= P0^1;
sbit GREEN_A= P0^2;
sbit RED_B= P0^3;
sbit YELLOW_B= P0^4;
sbit GREEN_B= P0^5;
uchar Time_Count=0,Flash_Count= 0,Operation_Type= 1;
void To_INT () interrupt 1
{
TH0 = -50000/256;
TL0 = -50000%256;
switch (Operation_Type)
{
case 1:
RED_A= 0;YELLOW_A= 0;GREEN_A= 1;
RED_B= 1;YELLOW_B= 0;GREEN_B= 0;
if(++Time_Count !=100) return;
Time_Count = 0;
Operation_Type= 2;
break;
case 2:
if(++Time_Count !=8) return;
Time_Count = 0;
YELLOW_A= !YELLOW_A;GREEN_A= 0;
if (++Flash_Count != 10) return;
Flash_Count = 0;
Operation_Type= 3;
break;
case 3:
RED_A= 0;YELLOW_A= 0;GREEN_A= 0;
RED_B= 0;YELLOW_B= 0;GREEN_B= 1;
if (++Flash_Count != 100) return;
Time_Count = 0;
Operation_Type= 4;
break;
case 4:
if(++Time_Count !=8) return;
Time_Count =0;
YELLOW_B= !YELLOW_B;GREEN_B= 0;
if (++Flash_Count != 10) return;
Flash_Count = 0;
Operation_Type = 1;
break;
}
}
void main()
{
TMOD = 0x01;
IE = 0x82;
TR0 = 1;
while(1);
}
编译结果:
linking...
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: MAIN
MODULE: 定时器控制交通指示灯.obj (定时器控_平煌╛甘镜?
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?MAIN?定时器控_平煌╛甘镜?
*** WARNING L5: CODE SPACE MEMORY OVERLAP
FROM: 000BH
TO: 000DH
*** ERROR L118: REFERENCE MADE TO ERRONEOUS EXTERNAL
SYMBOL: MAIN
MODULE: C:\KEIL\C51\LIB\C51S.LIB (?C_INIT)
ADDRESS: 0989H
Program Size: data=19.0 xdata=0 code=657
Target not created 展开
#define uchar unsigned char
#define uint unsigned int
sbit RED_A= P0^0;
sbit YELLOW_A= P0^1;
sbit GREEN_A= P0^2;
sbit RED_B= P0^3;
sbit YELLOW_B= P0^4;
sbit GREEN_B= P0^5;
uchar Time_Count=0,Flash_Count= 0,Operation_Type= 1;
void To_INT () interrupt 1
{
TH0 = -50000/256;
TL0 = -50000%256;
switch (Operation_Type)
{
case 1:
RED_A= 0;YELLOW_A= 0;GREEN_A= 1;
RED_B= 1;YELLOW_B= 0;GREEN_B= 0;
if(++Time_Count !=100) return;
Time_Count = 0;
Operation_Type= 2;
break;
case 2:
if(++Time_Count !=8) return;
Time_Count = 0;
YELLOW_A= !YELLOW_A;GREEN_A= 0;
if (++Flash_Count != 10) return;
Flash_Count = 0;
Operation_Type= 3;
break;
case 3:
RED_A= 0;YELLOW_A= 0;GREEN_A= 0;
RED_B= 0;YELLOW_B= 0;GREEN_B= 1;
if (++Flash_Count != 100) return;
Time_Count = 0;
Operation_Type= 4;
break;
case 4:
if(++Time_Count !=8) return;
Time_Count =0;
YELLOW_B= !YELLOW_B;GREEN_B= 0;
if (++Flash_Count != 10) return;
Flash_Count = 0;
Operation_Type = 1;
break;
}
}
void main()
{
TMOD = 0x01;
IE = 0x82;
TR0 = 1;
while(1);
}
编译结果:
linking...
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: MAIN
MODULE: 定时器控制交通指示灯.obj (定时器控_平煌╛甘镜?
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?MAIN?定时器控_平煌╛甘镜?
*** WARNING L5: CODE SPACE MEMORY OVERLAP
FROM: 000BH
TO: 000DH
*** ERROR L118: REFERENCE MADE TO ERRONEOUS EXTERNAL
SYMBOL: MAIN
MODULE: C:\KEIL\C51\LIB\C51S.LIB (?C_INIT)
ADDRESS: 0989H
Program Size: data=19.0 xdata=0 code=657
Target not created 展开
展开全部
程序没有错误,编译可以成功,hex文件也可以生成,你看看你的软件是否破解完全,另外你的主函数里面可能含有中文字符,在确保软件破解完全的基础上新建一个工程把程序主函数部分重写一下,另外你也可以把这个工程关掉打开你以前写的程序编译一下试试看
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我试了一下 编译后没有错误也没有警告
要不你改改头文件试试
要不你改改头文件试试
追问
请问怎样改,我试了一次还是不行。不能生成hex文件。用Keil uVision4编译的
追答
#include 你试试 我也不看不懂那些英文什么意思 或许是你的文件没保存好 你检查一下
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询