51单片机c语言编程子函数调用问题 程序功能是实现四个独立按键控制数码管四个位的段选来动态扫描
下面是代码运行不了四个warningkeil提示Buildtarget'Target1'assemblingSTARTUP.A51...compiling1.c...1....
下面是代码 运行不了 四个warning
keil提示 Build target 'Target 1'
assembling STARTUP.A51...
compiling 1.c...
1.C(107): warning C206: 'DigDisplay': missing function-prototype
linking...
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?DIGDISPALY?1
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: DIGDISPLAY
MODULE: 1.obj (1)
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: DIGDISPLAY
MODULE: 1.obj (1)
ADDRESS: 0079H
Program Size: data=13.0 xdata=0 code=213
creating hex file from "1"...
"1" - 0 Error(s), 4 Warning(s).
#include<reg52.h>
typedef unsigned char u8;
typedef unsigned int u16;
u8 code smgduan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;
sbit k1=P3^1;
sbit k2=P3^0;
sbit k3=P3^2;
sbit k4=P3^3;
u8 a,b,c,d;
void delay(u16 i)
{
while(i--);
}
void keypros() //abcd为按键次数
{
if(k1==0)
{
delay(100);
a=a+1;
delay(100);
}
if(k2==0)
{
delay(100);
b=b+1;
delay(100);
}
if(k3==0)
{
delay(100);
c=c+1;
delay(100);
}
if(k4==0)
{
delay(100);
d=d+1;
delay(100);
}
}
void DigDispaly()
{
u8 i;
for(i=0;i<4;i++)
{
switch(i) //位选,选择点亮的数码管,
{
case(0):
LSA=0;LSB=0;LSC=0;P0=smgduan[a]; delay(100);P0=0x00; break;//显示第0位
case(1):
LSA=1;LSB=0;LSC=0;P0=smgduan[b]; delay(100);P0=0x00; break;//显示第1位
case(2):
LSA=0;LSB=1;LSC=0;P0=smgduan[c]; delay(100);P0=0x00; break;//显示第2位
case(3):
LSA=1;LSB=1;LSC=0;P0=smgduan[d]; delay(100);P0=0x00; break;//显示第3位
}
}
}
void main()
{
a=0;b=0;c=0;d=0;
while(1)
{
keypros();
if(a==8)
{
a=1;
}
if(b==8)
{
b=1;
}
if(c==8)
{
c=1;
}
if(d==8)
{
d=1;
}
DigDisplay();
}
} 展开
keil提示 Build target 'Target 1'
assembling STARTUP.A51...
compiling 1.c...
1.C(107): warning C206: 'DigDisplay': missing function-prototype
linking...
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?DIGDISPALY?1
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: DIGDISPLAY
MODULE: 1.obj (1)
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: DIGDISPLAY
MODULE: 1.obj (1)
ADDRESS: 0079H
Program Size: data=13.0 xdata=0 code=213
creating hex file from "1"...
"1" - 0 Error(s), 4 Warning(s).
#include<reg52.h>
typedef unsigned char u8;
typedef unsigned int u16;
u8 code smgduan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
sbit LSA=P2^2;
sbit LSB=P2^3;
sbit LSC=P2^4;
sbit k1=P3^1;
sbit k2=P3^0;
sbit k3=P3^2;
sbit k4=P3^3;
u8 a,b,c,d;
void delay(u16 i)
{
while(i--);
}
void keypros() //abcd为按键次数
{
if(k1==0)
{
delay(100);
a=a+1;
delay(100);
}
if(k2==0)
{
delay(100);
b=b+1;
delay(100);
}
if(k3==0)
{
delay(100);
c=c+1;
delay(100);
}
if(k4==0)
{
delay(100);
d=d+1;
delay(100);
}
}
void DigDispaly()
{
u8 i;
for(i=0;i<4;i++)
{
switch(i) //位选,选择点亮的数码管,
{
case(0):
LSA=0;LSB=0;LSC=0;P0=smgduan[a]; delay(100);P0=0x00; break;//显示第0位
case(1):
LSA=1;LSB=0;LSC=0;P0=smgduan[b]; delay(100);P0=0x00; break;//显示第1位
case(2):
LSA=0;LSB=1;LSC=0;P0=smgduan[c]; delay(100);P0=0x00; break;//显示第2位
case(3):
LSA=1;LSB=1;LSC=0;P0=smgduan[d]; delay(100);P0=0x00; break;//显示第3位
}
}
}
void main()
{
a=0;b=0;c=0;d=0;
while(1)
{
keypros();
if(a==8)
{
a=1;
}
if(b==8)
{
b=1;
}
if(c==8)
{
c=1;
}
if(d==8)
{
d=1;
}
DigDisplay();
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询