没有看到main |
2384298858 发表于 2024-1-9 15:19 在项目属性中,选中创建HEX的选项 |
不用看Warning,要看error, 提示你变量重复定义了,你读读编译结果,不认识的单词百度一下 |
![]() |
2384298858 发表于 2024-1-9 16:37 所以你不要贴warning,要贴error才是问题所在。 你在你的文件里面搜“count”就知道问题在哪里了。 |
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS SYMBOL: COUNT MODULE: .\Objects\main.obj (MAIN) 这一条是你重复定义 COUNT 其它的没问题, 因为你没调用,所以编译器告诉你这些函数不会编译 |
void Time_Init() 这个函数你写了完整的代码。 然而没有任何地方引用过这个函数。 所以编译器不知所措,把这个函数的代码扔掉了,顺便丢给你一个警告。 |
人中狼 发表于 2024-1-9 16:09 Build target 'Target 1' linking... *** ERROR L104: MULTIPLE PUBLIC DEFINITIONS SYMBOL: COUNT MODULE: .\Objects\main.obj (MAIN) *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS SEGMENT: ?PR?TIMERINIT?MAIN *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS SEGMENT: ?PR?TIME_INIT?MAIN *** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS SEGMENT: ?C_INITSEG Program Size: data=8.2 xdata=15 code=631 Target not created. Build Time Elapsed: 00:00:00 |
把编译结果信息都贴出来吧 |
程序从哪个函数执行?? |
void main ()?????? |
人中狼 发表于 2024-1-9 15:14 您好 Target not created. 是这个问题 就是我要构建Hex格式的文件构建不了 可以帮忙看一下吗 |
只是一个函数未调用的警告而已,不影响的 |
完整代码如下 #include<reg52.h> #include<intrins.h> #define uchar unsigned char #define uint unsigned int sbit Key1=P2^0; sbit Key2=P2^1; sbit Key3=P2^2; sbit Key4=P2^3; sbit LED=P2^6; sbit SPK=P2^7; void delay(uint ms); uchar count,shi,ge,countdown,state; uchar Buf[2]={0}; uchar code DispBitCode[] = {0xfe,0xfd}; uchar code DispCode[] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xFF,0xBF} ; uchar Count=0; uint time=0; uint show_time=0; bit start = 0; bit alarm = 0; void Delay(uint x) { while(--x); } void DisPlay (uchar *DispBuf) { uchar k; for(k=0; k<2; k++) { P1=DispBitCode[k]; P0=DispCode[DispBuf[k]]; Delay (500); } } void KeyScan (void) { { if(Key1==0) { delay(15); TR0=0; state=1; } if(state==1) { delay(15); } } if(Key2==0) { delay(15); if(Key2==0) { if(start==0) { if(time<59) time++; else time=0; show_time=time; } while(!Key2); } } if(Key3==0) { delay(15); if(Key3==0) { if(start==0) { if(time>0) time--; else time=59; show_time=time; } while(!Key3); } } if(Key4==0) { delay(15); TR0=1; state=0; } } void TimerInit (void) { TMOD=0x11; TH0=(65535-50000)/256; TL0=(65535-50000)%256; TH1=0xfe; TL1=0x00; TR1=0; ET1=1; TR0=0; ET0=1; EA=1; } void openAlarm (void) { TR1=1; LED=0; } void closeAlarm(void) { TR1 = 0; LED=1; } void Time_Init() { LED=1; time=10; show_time =time; while(1) { Buf[0]= show_time%10; Buf[1]= show_time/10; DisPlay(Buf); KeyScan(); if(1 == alarm) { TR0 = 0; openAlarm(); } else closeAlarm(); } return; } void Timer0(void) interrupt 1 { TH0=(5535 - 50000)/256; TL0=(65535 - 50000)%256; count++; if(20==Count) { Count = 0; show_time--; if(0==show_time) { alarm=1; } } } void Timerl(void) interrupt 3 { TH1=0xfd; TL1=0x00; SPK=~SPK; } |