用keil编译时出错了,看了网上很多解答,不过我并没有自定义头文件,不知道问题出在哪
以下是我的两个c文件,下面是错误代码。求高手解答
#include<reg52.h>
#include<intrins.h>
#include<lcd.c>
#define uchar unsigned char
sbit SCLK=P3^6;
sbit DSIO=P3^4;
sbit CE=P3^5;
uchar i;
uchar code tab_r[]={0x81,0x83,0x85,0x87,0x89,0x8b,0x8d};
uchar code tab_w[]={0x82,0x84,0x86,0x88,0x8a,0x8c,0x8e};
uchar Time[8]={0x00,0x00,0x19,0x17,0x05,0x06,0x14};
uchar DSread(uchar add)
{
uchar date,date1;
SCLK=0;
_nop_();
CE=1;
_nop_();
for(i=0;i<8;i++)
{
DSIO=add&1;
add>>=1;
SCLK=1;
_nop_();
SCLK=0;
_nop_();
}
_nop_();
for(i=0;i<8;i++)
{
date1=DSIO;
date>>=1;
date|=date1<<7;
SCLK=1;
_nop_();
SCLK=0;
_nop_();
}
CE=0;
_nop_();
SCLK=1;
_nop_();
DSIO=0;
_nop_();
DSIO=1;
_nop_();
return date;
}
void DSwrite(uchar add,uchar date)
{
SCLK=0;
_nop_();
CE=1;
_nop_();
for(i=0;i<8;i++)
{
DSIO=add&1;
add>>=1;
SCLK=1;
_nop_();
SCLK=0;
_nop_();
}
for(i=0;i<8;i++)
{
DSIO=date&1;
date>>=1;
SCLK=1;
_nop_();
SCLK=0;
_nop_();
}
CE=0;
_nop_();
}
void DS1302inte()
{
DSwrite(0x8e,0x00);
for(i=0;i<7;i++)
{
DSwrite(tab_w[i],Time[i]);
}
DSwrite(0x8e,0x80);
}
void DSreadTime()
{
for(i=0;i<7;i++)
{
Time[i]=DSread(tab_r[i]);
}
}
void LCDdis()
{
P0=0x00;
inte();
write_date(num[Time[6]&0xf0]);
}
void main()
{
void DS1302inte();
while(1)
{
void DSreadTime();
void LCDdis();
}
}
#include<reg52.h>
#define uchar unsigned char
sbit rs=P2^6;
sbit rw=P2^5;
sbit en=P2^7;
uchar code num[]="0123456789" ;
void delay(uchar i)
{
uchar j,k;
for(j=0;j<i;j++)
for(k=0;k<10;k++);
}
void write_com(uchar com)
{
rs=0;
P0=com;
en=1;
delay(10);
en=0;
}
void write_date(uchar date)
{
rs=1;
P0=date;
en=1;
delay(10);
en=0;
}
void inte()
{
rw=0;
write_com(0x01);
delay(10);
write_com(0x38);
delay(10);
write_com(0x38);
delay(10);
write_com(0x0c);
delay(10);
write_com(0x06);
delay(10);
}
Build target 'Target 1'
assembling STARTUP.A51...
compiling ds1302.c...
compiling lcd.c...
linking...
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: NUM
MODULE: lcd.obj (LCD)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: INTE
MODULE: lcd.obj (LCD)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: _WRITE_DATE
MODULE: lcd.obj (LCD)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: _WRITE_COM
MODULE: lcd.obj (LCD)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: _DELAY
MODULE: lcd.obj (LCD)
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?DS1302INTE?DS1302
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?DSREADTIME?DS1302
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?LCDDIS?DS1302
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?_WRITE_DATE?LCD
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?INTE?LCD
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?CO?LCD
Program Size: data=18.0 xdata=0 code=581
Target not created
以下是我的两个c文件,下面是错误代码。求高手解答
#include<reg52.h>
#include<intrins.h>
#include<lcd.c>
#define uchar unsigned char
sbit SCLK=P3^6;
sbit DSIO=P3^4;
sbit CE=P3^5;
uchar i;
uchar code tab_r[]={0x81,0x83,0x85,0x87,0x89,0x8b,0x8d};
uchar code tab_w[]={0x82,0x84,0x86,0x88,0x8a,0x8c,0x8e};
uchar Time[8]={0x00,0x00,0x19,0x17,0x05,0x06,0x14};
uchar DSread(uchar add)
{
uchar date,date1;
SCLK=0;
_nop_();
CE=1;
_nop_();
for(i=0;i<8;i++)
{
DSIO=add&1;
add>>=1;
SCLK=1;
_nop_();
SCLK=0;
_nop_();
}
_nop_();
for(i=0;i<8;i++)
{
date1=DSIO;
date>>=1;
date|=date1<<7;
SCLK=1;
_nop_();
SCLK=0;
_nop_();
}
CE=0;
_nop_();
SCLK=1;
_nop_();
DSIO=0;
_nop_();
DSIO=1;
_nop_();
return date;
}
void DSwrite(uchar add,uchar date)
{
SCLK=0;
_nop_();
CE=1;
_nop_();
for(i=0;i<8;i++)
{
DSIO=add&1;
add>>=1;
SCLK=1;
_nop_();
SCLK=0;
_nop_();
}
for(i=0;i<8;i++)
{
DSIO=date&1;
date>>=1;
SCLK=1;
_nop_();
SCLK=0;
_nop_();
}
CE=0;
_nop_();
}
void DS1302inte()
{
DSwrite(0x8e,0x00);
for(i=0;i<7;i++)
{
DSwrite(tab_w[i],Time[i]);
}
DSwrite(0x8e,0x80);
}
void DSreadTime()
{
for(i=0;i<7;i++)
{
Time[i]=DSread(tab_r[i]);
}
}
void LCDdis()
{
P0=0x00;
inte();
write_date(num[Time[6]&0xf0]);
}
void main()
{
void DS1302inte();
while(1)
{
void DSreadTime();
void LCDdis();
}
}
#include<reg52.h>
#define uchar unsigned char
sbit rs=P2^6;
sbit rw=P2^5;
sbit en=P2^7;
uchar code num[]="0123456789" ;
void delay(uchar i)
{
uchar j,k;
for(j=0;j<i;j++)
for(k=0;k<10;k++);
}
void write_com(uchar com)
{
rs=0;
P0=com;
en=1;
delay(10);
en=0;
}
void write_date(uchar date)
{
rs=1;
P0=date;
en=1;
delay(10);
en=0;
}
void inte()
{
rw=0;
write_com(0x01);
delay(10);
write_com(0x38);
delay(10);
write_com(0x38);
delay(10);
write_com(0x0c);
delay(10);
write_com(0x06);
delay(10);
}
Build target 'Target 1'
assembling STARTUP.A51...
compiling ds1302.c...
compiling lcd.c...
linking...
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: NUM
MODULE: lcd.obj (LCD)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: INTE
MODULE: lcd.obj (LCD)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: _WRITE_DATE
MODULE: lcd.obj (LCD)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: _WRITE_COM
MODULE: lcd.obj (LCD)
*** ERROR L104: MULTIPLE PUBLIC DEFINITIONS
SYMBOL: _DELAY
MODULE: lcd.obj (LCD)
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?DS1302INTE?DS1302
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?DSREADTIME?DS1302
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?LCDDIS?DS1302
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?_WRITE_DATE?LCD
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?INTE?LCD
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?CO?LCD
Program Size: data=18.0 xdata=0 code=581
Target not created