请问这里的warning 是什么意思。还有能帮忙解释下这个程序吗?新手表示看不懂原作者想法,现在这谢谢呢
#include <reg51.h>#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar dis_buf; //显示缓存
uchar temp;
uchar key; //键顺序吗
void delay0(uchar x); //x*0.14MS
sbit LCD_RW = P2^5;
sbit LCD_RS = P2^6;
sbit LCD_EN = P2^7;
uchar cdis1[16] = {" KEY NUMBER "};
uchar cdis2[16] = {" KEY-CODE: H "};
#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();};
/*************************************************************/
/* */
/* 延时子程序 */
/* */
/*************************************************************/
void delay(uchar x)
{ uchar j;
while((x--)!=0)
{ for(j=0;j<125;j++)
{;}
}
}
bit lcd_busy()
{
bit result;
LCD_RS = 0;
LCD_RW = 1;
LCD_EN = 1;
delayNOP();
result = (bit)(P0 & 0x80);
LCD_EN = 0;
return result;
}
void lcd_wcmd(uchar cmd)
{
while(lcd_busy());
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 0;
_nop_();
_nop_();
P0 = cmd;
delayNOP();
LCD_EN = 1;
delayNOP();
LCD_EN = 0;
}
void lcd_wdat(uchar dat)
{
while(lcd_busy());
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 0;
P0 = dat;
delayNOP();
LCD_EN = 1;
delayNOP();
LCD_EN = 0;
}
void lcd_init()
{
delay(15);
lcd_wcmd(0x38);
delay(5);
lcd_wcmd(0x38);
delay(5);
lcd_wcmd(0x38);
delay(5);
lcd_wcmd(0x0c);
delay(5);
lcd_wcmd(0x06);
delay(5);
lcd_wcmd(0x01);
delay(5);
}
void lcd_pos(uchar pos)
{
lcd_wcmd(pos | 0x80);
}
void keyscan(void)
{
temp = 0;
P1 = 0xf0;
delay(1);
temp = P1;
temp = temp & 0xf0;
temp = ~((temp >> 4) | 0xf0);
if (temp == 1) key = 0;
else if (temp == 2) key = 1;
else if (temp == 4) key = 2;
else if (temp == 8) key = 3;
else key = 16; //0000 0000
P1 = 0x0f;
delay(1);
temp = P1;
temp = temp & 0x0f;
temp = ~(temp | 0xf0);
if (temp == 2) key = key +0;
else if(temp == 4) key = key +4;
else if (temp == 8) key = key + 8;
else key =16;
dis_buf = key;
dis_buf = dis_buf & 0x0f;
if (dis_buf > 9) dis_buf = dis_buf + 0x37;//0011 1111
else dis_buf = dis_buf + 0x30; //0011 0000
}
void keydown(void)
{
P1 = 0xf0;
if (P1 != 0xf0) keyscan();
}
void main()
{
uchar m;
P0 = 0xff;
P1 = 0xff;
delay(10);
lcd_init();
lcd_pos(0);
m = 0;
while(cdis1[m] != '\0'){lcd_wdat(cdis1[m]); m++;}
lcd_pos(0x40);
m = 0;
while(cdis2[m] != '\0'){lcd_wdat(cdis2[m]); m++;}
dis_buf = 0x2d;//0010 1100
while(1)
{
keydowm();
lcd_pos(0x4c);
lcd_wdat(dis_buf);
}
}
return:
Build target 'Target 1'
assembling STARTUP.A51...
compiling demo.c...
DEMO.C(155): warning C206: 'keydowm': missing function-prototype
linking...
*** WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS
SEGMENT: ?PR?KEYDOWN?DEMO
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: KEYDOWM
MODULE: demo.obj (DEMO)
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYDOWM
MODULE: demo.obj (DEMO)
ADDRESS: 015DH
Program Size: data=44.1 xdata=0 code=564
creating hex file from "demo"...
"demo" - 0 Error(s), 4 Warning(s).
原程序是:
/********************************************************************************
* 描述: *
* 矩阵键盘1602液晶显示键值 *
* 连接方法:JP8(P1) 与JP4(矩阵键盘接口) 连接 *
* 矩阵键盘定义: *
* P1.1-P1.4为列线,P1.4-P1.7为行线 *
* 喇叭接P1.5口 矩阵键盘P1口, *
* 注意:请将JP165短路冒断开 *
********************************************************************************/
#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar dis_buf; //显示缓存
uchar temp;
uchar key; //键顺序吗
void delay0(uchar x); //x*0.14MS
sbit LCD_RW = P2^5;
sbit LCD_RS = P2^6;
sbit LCD_EN = P2^7;
uchar cdis1[16] = {" KEY NUMBER "};
uchar cdis2[16] = {" KEY-CODE: H "};
#define delayNOP(); {_nop_();_nop_();_nop_();_nop_();};
/*************************************************************/
/* */
/* 延时子程序 */
/* */
/*************************************************************/
void delay(uchar x)
{ uchar j;
while((x--)!=0)
{ for(j=0;j<125;j++)
{;}
}
}
/*************************************************************/
/* */
/*检查LCD忙状态 */
/*lcd_busy为1时,忙,等待。lcd-busy为0时,闲,可写指令与数据 */
/* */
/*************************************************************/
bit lcd_busy()
{
bit result;
LCD_RS = 0;
LCD_RW = 1;
LCD_EN = 1;
delayNOP();
result = (bit)(P0&0x80);
LCD_EN = 0;
return(result);
}
/*******************************************************************/
/* */
/*写指令数据到LCD */
/*RS=L,RW=L,E=高脉冲,D0-D7=指令码。 */
/* */
/*******************************************************************/
void lcd_wcmd(uchar cmd)
{
while(lcd_busy());
LCD_RS = 0;
LCD_RW = 0;
LCD_EN = 0;
_nop_();
_nop_();
P0 = cmd;
delayNOP();
LCD_EN = 1;
delayNOP();
LCD_EN = 0;
}
/*******************************************************************/
/* */
/*写显示数据到LCD */
/*RS=H,RW=L,E=高脉冲,D0-D7=数据。 */
/* */
/*******************************************************************/
void lcd_wdat(uchar dat)
{
while(lcd_busy());
LCD_RS = 1;
LCD_RW = 0;
LCD_EN = 0;
P0 = dat;
delayNOP();
LCD_EN = 1;
delayNOP();
LCD_EN = 0;
}
/*************************************************************/
/* */
/* LCD初始化设定 */
/* */
/*************************************************************/
void lcd_init()
{
delay(15);
lcd_wcmd(0x38); //16*2显示,5*7点阵,8位数据
delay(5);
lcd_wcmd(0x38);
delay(5);
lcd_wcmd(0x38);
delay(5);
lcd_wcmd(0x0c); //显示开,关光标
delay(5);
lcd_wcmd(0x06); //移动光标
delay(5);
lcd_wcmd(0x01); //清除LCD的显示内容
delay(5);
}
/*************************************************************/
/* */
/* 设定显示位置 */
/* */
/*************************************************************/
void lcd_pos(uchar pos)
{
lcd_wcmd(pos | 0x80); //数据指针=80+地址变量
}
/*************************************************************/
/* */
/* 键扫描子程序 (4*3 的矩阵) P1.4 P1.5 P1.6 P1.7为行 */
/* P1.1 P1.2 P1.3为列 */
/* */
/*************************************************************/
void keyscan(void)
{ temp = 0;
P1=0xF0; //高四位输入 行为高电平 列为低电平
delay(1);
temp=P1; //读P1口
temp=temp&0xF0; //屏蔽低四位
temp=~((temp>>4)|0xF0);
if(temp==1) // p1.4 被拉低
key=0;
else if(temp==2) // p1.5 被拉低
key=1;
else if(temp==4) // p1.6 被拉低
key=2;
else if(temp==8) // p1.7 被拉低
key=3;
else
key=16;
P1=0x0F; //低四位输入 列为高电平 行为低电平
delay(1);
temp=P1; //读P1口
temp=temp&0x0F;
temp=~(temp|0xF0);
if(temp==2) // p1.1 被拉低
key=key+0;
else if(temp==4) // p1.2 被拉低
key=key+4;
else if(temp==8) // p1.3 被拉低
key=key+8;
else
key=16;
dis_buf = key; //键值入显示缓存
dis_buf = dis_buf & 0x0f;
if(dis_buf>9) //转换为ASCII码
dis_buf = dis_buf+0x37;
else
dis_buf = dis_buf+0x30;
}
/*************************************************************/
/* */
/*判断键是否按下 */
/* */
/*************************************************************/
void keydown(void)
{
P1=0xF0;
if(P1!=0xF0) //判断按键是否按下 如果按钮按下 会拉低P1其中的一个端口
{
keyscan();
}
}
/*************************************************************/
/* */
/* 主程序 */
/* */
/*************************************************************/
main()
{
uchar m;
P0=0xFF; //置P0口
P1=0xFF; //置P1口
delay(10); //延时
lcd_init(); //初始化LCD
lcd_pos(0); //设置显示位置为第一行的第1个字符
m = 0;
while(cdis1[m] != '\0')
{ //显示字符
lcd_wdat(cdis1[m]);
m++;
}
lcd_pos(0x40); //设置显示位置为第二行第1个字符
m = 0;
while(cdis2[m] != '\0')
{
lcd_wdat(cdis2[m]); //显示字符
m++;
}
dis_buf = 0x2d; //显示字符"-"
while(1)
{
keydown();
lcd_pos(0x4c);
lcd_wdat(dis_buf); //第一位数显示
}
}
/************************************************************/
[ 本帖最后由 waja 于 2013-3-30 09:09 编辑 ]