multiple call to segment
compiling 时钟.c...
linking...
***WARNING L15:MULTIPLE CALL TO SEGMENT
SEGMENT: ?PR?RESPONS?_____
CALLER1: ?PR?TIMER0?_____
CALLER2: ?C_C51STARTUP
creating hex file from "时钟“....
"时钟”-0 Error(s), 1Warning(s).
请问一下,这个问题要怎么解决?
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
#include"24C02.h"
sbit dula=P2^6;
sbit wela=P2^7;
sbit rs=P3^5; //定义1602液晶RS端
sbit lcden=P3^4; //定义1602液晶LCDEN端
sbit s1=P3^0; //定义按键--功能键
sbit s2=P3^1; //定义按键--增大键
sbit s3=P3^2; //定义按键--减小键
sbit rd=P3^7;
sbit beep=P2^3; //定义蜂鸣器端
uchar count,s1num;
char miao,shi,fen;
uchar code table[]="2008-9-30 MON"; //15个定义初始上电时液晶默认显示状态
void delay(uint z) //延时函数
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void di() //蜂鸣器发声函数
{
beep=0;
delay(100);
beep=1;
}
void write_com(uchar com) //液晶写命令函数
{
rs=0;
lcden=0;
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_date(uchar date) //液晶写数据函数
{
rs=1;
lcden=0;
P0=date;
delay(5);
lcden=1;
delay(5);
lcden=0;
}
void write_sfm(uchar add,uchar date) //写时分秒函数
{
uchar shi,ge;
shi=date/10;
ge=date%10;
write_com(0x80+0x40+add); //设置显示位置
write_date(0x30+shi); //送去液晶显示十位
write_date(0x30+ge); //送去液晶显示个位
}
void init() //初始化函数
{
uchar num;
rd=0; //软件将矩阵按键第4列一端置低用于分解出独立按键
dula=0;
wela=0;
lcden=0;
fen=0;
miao=0;
shi=0;
count=0;
s1num=0;
init_24c02();
write_com(0x38);
write_com(0x0c);
write_com(0x06);
write_com(0x01);
write_com(0x80);
for(num=0;num<15;num++)
{
write_date(table[num]);
delay(5);
}
write_com(0x80+0x40+6); //写出时间显示部分的两个冒号
write_date(':');
delay(5);
write_com(0x80+0x40+9);
write_date(':');
delay(5);
miao=read_add(1); //首次上电从AT24C02中读取出存储的数据
fen=read_add(2);
shi=read_add(3);
write_sfm(10,miao); //分别送去液晶显示
write_sfm(7,fen);
write_sfm(4,shi);
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
}
void keyscan() //按键扫描函数
{
if(s1==0)
{
delay(5);
if(s1==0) //确定功能键被按下
{
s1num++; //功能键按下次数记录
while(!s1);
di();
if(s1num==1)
{
TR0=0; //关闭定时器
write_com(0x80+0x40+10); //光标定位在秒的位置
write_com(0x0f); //光标开始闪烁
}
if(s1num==2) //第二次按下光标闪烁地位在分钟位置
{
write_com(0x80+0x40+7);
}
if(s1num==3) //第三次按下光标闪烁定位在小时位置
{
write_com(0x80+0x40+4);
}
if(s1num==4) //第四次按下
{
s1num=0; //记录按键数清0;
write_com(0x0c); //取消光标闪烁
TR0=1; //启动定时器使时钟开始走
}
}
}
if(s1num!=0) //只有功能键被按下后,增大和减小键才有效
{
if(s2==0)
{
delay(5);
if(s2==0)
{
while(!s2);
di();
if(s1num==1)
{
miao++;
if(miao==60)
miao=0;
write_sfm(10,miao);
write_com(0x80+0x40+10);
write_add(1,miao); //数据改变立即存入24c02
}
if(s1num==2)
{
fen++;
if(fen==60)
fen=0;
write_sfm(7,fen);
write_com(0x80+0x40+7);
write_add(2,fen);
}
if(s1num==3)
{
shi++;
if(shi==24)
shi=0;
write_sfm(4,shi);
write_com(0x80+0x40+4);
write_add(3,shi);
}
}
}
if(s3==0)
{
delay(5);
if(s3==0)
{
while(!s3);
di();
if(s1num==1)
{
miao--;
if(miao==-1)
miao=59;
write_sfm(10,miao);
write_com(0x80+0x40+10);
write_add(1,miao);
}
if(s1num==2)
{
fen--;
if(fen==-1)
fen=59;
write_sfm(7,fen);
write_com(0x80+0x40+7);
write_add(2,fen);
}
if(s1num==3)
{
shi--;
if(shi==-1)
shi=23;
write_sfm(4,shi);
write_com(0x80+0x40+4);
write_add(3,shi);
}
}
}
}
}
void main() //主函数
{
init();
while(1)
{
keyscan();
}
}
void timer0() interrupt 1 //定时器0中断服务程序
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
count++;
if(count==20)
{
count=0;
miao++;
if(miao==60)
{
miao=0;
fen++;
if(fen==60)
{
fen=0;
shi++;
if(shi==24)
{
shi=0;
}
write_sfm(4,shi);
write_add(3,shi);
}
write_sfm(7,fen);
write_add(2,fen);
}
write_sfm(10,miao);
write_add(1,miao);
}
}
-------------------------------------------下面是EEPROM的操作函数-------------------------
bit write=0; //写24C02的标志位;
sbit sda=P2^0;
sbit scl=P2^1;
void delay0()
{;;}
void start() //开始信号
{
sda=1;
delay0();
scl=1;
delay0();
sda=0;
delay0();
}
void stop() //停止
{
sda=0;
delay0();
scl=1;
delay0();
sda=1;
delay0();
}
void respons() //应答
{
uchar i;
scl=1;
delay0();
while((sda==1)&&(i<250))i++;
scl=0;
delay0();
}
void init_24c02() //IIC初始化函数
{
sda=1;
delay0();
scl=1;
delay0();
}
void write_byte(uchar date) //写一个字节函数
{
uchar i,temp;
temp=date;
for(i=0;i<8;i++)
{
temp=temp<<1;
scl=0;
delay0();
sda=CY;
delay0();
scl=1;
delay0();
}
scl=0;
delay0();
sda=1;
delay0();
}
uchar read_byte() //读一个字节函数
{
uchar i,k;
scl=0;
delay0();
sda=1;
delay0();
for(i=0;i<8;i++)
{
scl=1;
delay0();
k=(k<<1)|sda;
scl=0;
delay0();
}
return k;
}
void write_add(uchar address,uchar date) //指定地址写一个字节
{
start();
write_byte(0xa0);
respons();
write_byte(address);
respons();
write_byte(date);
respons();
stop();
}
char read_add(uchar address) //指定地址读一个字节
{
uchar date;
start();
write_byte(0xa0);
respons();
write_byte(address);
respons();
start();
write_byte(0xa1);
respons();
date=read_byte();
stop();
return date;
}
--------------------------麻烦各位大虾看看,小弟我找了好久没找到,很郁闷------------谢谢了
怎么没有大虾帮忙的,只有人在笑,笑什么呢?谁帮我看看啊?
这个主要是由于你在中断函数里面调用了一个子函数。但这个函数之前已经在主函数或其它地方调用过了。当发生中断后,进入中断函数再次调用此函数的话,可能会引起冲突,造成错误。若要避免此问题,你可以编写一个功能相同的另一个子函数。你可以试试
void timer0() interrupt 1 //定时器0中断服务程序
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
count++;
if(count==20)
{
count=0;
miao++;
if(miao==60)
{
miao=0;
fen++;
if(fen==60)
{
fen=0;
shi++;
if(shi==24)
{
shi=0;
}
write_sfm(4,shi);
write_add(3,shi);
}
write_sfm(7,fen);
write_add(2,fen);
}
write_sfm(10,miao);
write_add(1,miao);
}
}
谢谢你,我去试试。
子函数是这个:SEGMENT: ?PR?RESPONS?_____
调用这个子函数的是这两个:
CALLER1: ?PR?TIMER0?_____
CALLER2: ?C_C51STARTUP
怎么画红色的是:
}
write_sfm(4,shi);
write_add(3,shi);
}
write_sfm(7,fen);
write_add(2,fen);
}
write_sfm(10,miao);
write_add(1,miao);
}
}
write_sfm(4,shi);
write_add(3,shi);
}
write_sfm(7,fen);
write_add(2,fen);
}
write_sfm(10,miao);
write_add(1,miao);你把这段删了就没问题了