| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 6076 人关注过本帖
标题:请问这里的warning 是什么意思。还有能帮忙解释下这个程序吗?新手表示看不 ...
只看楼主 加入收藏
waja
Rank: 2
等 级:论坛游民
帖 子:53
专家分:52
注 册:2012-7-27
结帖率:81.82%
收藏
已结贴  问题点数:20 回复次数:6 
请问这里的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 编辑 ]
搜索更多相关主题的帖子: warning include 
2013-03-30 09:03
m564522634
Rank: 2
等 级:论坛游民
帖 子:34
专家分:16
注 册:2010-9-1
收藏
得分:7 
看了下不是很清楚了,不知道你是怎么回事
2013-04-04 22:08
m564522634
Rank: 2
等 级:论坛游民
帖 子:34
专家分:16
注 册:2010-9-1
收藏
得分:0 
这程序写的
2013-04-04 22:09
小xiong
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
帖 子:388
专家分:1722
注 册:2013-2-8
收藏
得分:7 
keydowm没这个吧,改为keydown
2013-04-05 08:38
mengmen
Rank: 1
等 级:新手上路
帖 子:3
专家分:7
注 册:2013-3-18
收藏
得分:7 
....好长。
2013-04-07 21:15
BeyondXX
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2013-5-10
收藏
得分:0 
,看了头不大,都大了,好难呀
2013-05-10 00:32
q913794286
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2017-4-27
收藏
得分:0 
论m和n的区别
2017-04-27 10:08
快速回复:请问这里的warning 是什么意思。还有能帮忙解释下这个程序吗?新手表示 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033132 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved