本帖最后由 hceng 于 2013-11-27 10:50 编辑
一堆的warning
这个是主程序main.c
/////头文件/////
#include <REGX51.H>
#include "key.h"
#include "Led.h"
#include "MyType.h"
////main开始///
void main(void)
{
InitKeyboard();
while(1)
{
LEDL=~(KeyPress&0x00ff);
LEDH=~(KeyPress>>8);
}
if(KeyDown) //有键按下
{ //处理按下的键
if(KeyDown&KEY1)
{
LED1=~LED1;
KeyDown&=~KEY1;
}
if(KeyDown&KEY2)
{
LED2=~LED2;
KeyDown&=~KEY2;
}
if(KeyDown&KEY3)
{
LED3=~LED3;
KeyDown&=~KEY3;
}
if(KeyDown&KEY4)
{
LED4=~LED4;
KeyDown&=~KEY4;
}
if(KeyDown&KEY5)
{
LED5=~LED5;
KeyDown&=~KEY5;
}
if(KeyDown&KEY6)
{
LED6=~LED6;
KeyDown&=~KEY6;
}
if(KeyDown&KEY7)
{
LED7=~LED7;
KeyDown&=~KEY7;
}
if(KeyDown&KEY8)
{
LED8=~LED8;
KeyDown&=~KEY8;
}
if(KeyDown&KEY9)
{
LED9=~LED9;
KeyDown&=~KEY9;
}
if(KeyDown&KEY10)
{
LED10=~LED10;
KeyDown&=~KEY10;
}
if(KeyDown&KEY11)
{
LED11=~LED11;
KeyDown&=~KEY11;
}if(KeyDown&KEY12)
{
LED12=~LED12;
KeyDown&=~KEY12;
}
if(KeyDown&KEY13)
{
LED13=~LED13;
KeyDown&=~KEY13;
}if(KeyDown&KEY14)
{
LED14=~LED14;
KeyDown&=~KEY14;
}if(KeyDown&KEY15)
{
LED15=~LED15;
KeyDown&=~KEY15;
}if(KeyDown&KEY16)
{
LED16=~LED16;
KeyDown&=~KEY16;
}
}
if(KeyUp)//有键释放
{//处理释放的键
/* if(KeyUp&KEY1)
{
KeyUp&=~KEY1;
}
if(KeyUp&KEY2)
{
LED2=~LED2;
KeyUp&=~KEY2;
}
if(KeyUp&KEY3)
{
LED3=~LED3;
KeyUp&=~KEY3;
}
if(KeyUp&KEY4)
{
LED4=~LED4;
KeyUp&=~KEY4;
}
if(KeyUp&KEY5)
{
LED5=~LED5;
KeyUp&=~KEY5;
}
if(KeyUp&KEY6)
{
LED6=~LED6;
KeyUp&=~KEY6;
}
if(KeyUp&KEY7)
{
LED7=~LED7;
KeyUp&=~KEY7;
}
if(KeyUp&KEY8)
{
LED8=~LED8;
KeyUp&=~KEY8;
}
if(KeyUp&KEY9)
{
LED9=~LED9;
KeyUp&=~KEY9;
}
if(KeyUp&KEY10)
{
LED10=~LED10;
KeyUp&=~KEY10;
}
if(KeyDown&KEY11)
{
LED11=~LED11;
KeyUp&=~KEY11;
}if(KeyUp&KEY12)
{
LED12=~LED12;
KeyUp&=~KEY12;
}
if(KeyUp&KEY13)
{
LED13=~LED13;
KeyUp&=~KEY13;
}if(KeyUp&KEY14)
{
LED14=~LED14;
KeyUp&=~KEY14;
}if(KeyUp&KEY15)
{
LED15=~LED15;
KeyUp&=~KEY15;
}if(KeyDown&KEY16)
{
LED16=~LED16;
KeyUp&=~KEY16;
}*/
}
}
按键部分Key.c
/**************
中断方式按键设计,8-16个按键
*********************/
#include <REGX51.H>
#include "MyType.h"
#include "Key.h"
#include "config.h"
/*******************
函数功能:T0初始化,按键5ms扫描一次
入口参数:无
返回值:无
备注:无
***************************/
void InitTimer0(void)
{
TMOD&=0xf0;
TMOD|=0x01;
ET0=1;
TR0=1;
}
/******************
函数功能:键盘初始化
入口参数:无
返回值:无
备注:无
*********************/
void InitKeyboard(void)
{
KeyIOL=0xff;
KeyIOH=0xff;
KeyCurrent=0;
KeyPress=0;
KeyKeepPressTime=0;
KeyOld=0;
KeyLast=0;
KeyDown=0;
KeyUp=0;
InitTimer0();
KeyCanChange=1;
}
/********
函数功能:中断0的服务程序
入口参数:无
返回参数:无
备注:无
**********/
void Timer0Isr(void) interrupt 1
{
uint16 temp;
TH0=(65536-FCLK/1000/12*5+15)/256;//15是补充重装补偿
TL0=(65536-FCLK/1000/12*5+15)%256;
if(!KeyCanChange)return;
temp=GetKeyValueH();
temp<<=8;
KeyCurrent=temp;
temp=GetKeyValueL();
KeyCurrent|=temp;
if(KeyCurrent!=KeyOld)
{
KeyKeepPressTime=0;
KeyOld=KeyCurrent;
return;
}
else
{
KeyKeepPressTime++;
if(KeyKeepPressTime>=1)
{
KeyKeepPressTime=1;
KeyPress=KeyOld;
KeyDown|=(~KeyLast)&(KeyPress);
KeyUp|=KeyLast&(~KeyPress);
KeyLast=KeyPress;
}
}
}
头文件Key.h
#ifndef __KEY_H__
#define __KEY_H__
#include <REGX51.H>
#include "MyType.h"
extern volatile uint16 idata KeyCurrent,KeyOld,KeyKeepPressTime;
extern volatile uint16 idata KeyPress;
extern volatile uint16 idata KeyDown,KeyUp,KeyLast;
extern volatile uchar8 idata KeyCanChange;
void InitKeyboard(void);
#define KeyIOL P1
#define KeyIOH P3
#define GetKeyValueL() (~KeyIOL)
#define GetKeyValueH() (~KeyIOH)
#define KEY1 0x0001//相应按键按下相应LED点亮
#define KEY2 0x0002
#define KEY3 0x0004
#define KEY4 0x0008
#define KEY5 0x0010
#define KEY6 0x0020
#define KEY7 0x0040
#define KEY8 0x0080
#define KEY9 0x0100
#define KEY10 0x0200
#define KEY11 0x0400
#define KEY12 0x0800
#define KEY13 0x1000
#define KEY14 0x2000
#define KEY15 0x4000
#define KEY16 0x8000
#endif
keil给出的警告
Build target 'Target 1'compiling key.c...
compiling System.c...
linking...
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: KEYCANCHANGE
MODULE: key.obj (KEY)
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: KEYCURRENT
MODULE: key.obj (KEY)
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: KEYPRESS
MODULE: key.obj (KEY)
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: KEYLAST
MODULE: key.obj (KEY)
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: KEYDOWN
MODULE: key.obj (KEY)
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: KEYOLD
MODULE: key.obj (KEY)
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: KEYKEEPPRESSTIME
MODULE: key.obj (KEY)
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: KEYUP
MODULE: key.obj (KEY)
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYCURRENT
MODULE: key.obj (KEY)
ADDRESS: 00E7H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYPRESS
MODULE: key.obj (KEY)
ADDRESS: 00ECH
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYKEEPPRESSTIME
MODULE: key.obj (KEY)
ADDRESS: 00F1H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYOLD
MODULE: key.obj (KEY)
ADDRESS: 00F6H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYLAST
MODULE: key.obj (KEY)
ADDRESS: 00FBH
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYDOWN
MODULE: key.obj (KEY)
ADDRESS: 0100H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYUP
MODULE: key.obj (KEY)
ADDRESS: 0105H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYCANCHANGE
MODULE: key.obj (KEY)
ADDRESS: 010DH
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYCANCHANGE
MODULE: key.obj (KEY)
ADDRESS: 0024H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYCURRENT
MODULE: key.obj (KEY)
ADDRESS: 0034H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYCURRENT
MODULE: key.obj (KEY)
ADDRESS: 0048H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYOLD
MODULE: key.obj (KEY)
ADDRESS: 004BH
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYKEEPPRESSTIME
MODULE: key.obj (KEY)
ADDRESS: 0056H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYCURRENT
MODULE: key.obj (KEY)
ADDRESS: 005DH
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYOLD
MODULE: key.obj (KEY)
ADDRESS: 0064H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYKEEPPRESSTIME
MODULE: key.obj (KEY)
ADDRESS: 0068H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYKEEPPRESSTIME
MODULE: key.obj (KEY)
ADDRESS: 0071H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYOLD
MODULE: key.obj (KEY)
ADDRESS: 0081H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYPRESS
MODULE: key.obj (KEY)
ADDRESS: 0088H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYLAST
MODULE: key.obj (KEY)
ADDRESS: 008FH
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYPRESS
MODULE: key.obj (KEY)
ADDRESS: 0099H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYDOWN
MODULE: key.obj (KEY)
ADDRESS: 00A1H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYPRESS
MODULE: key.obj (KEY)
ADDRESS: 00AAH
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYLAST
MODULE: key.obj (KEY)
ADDRESS: 00B4H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYUP
MODULE: key.obj (KEY)
ADDRESS: 00BCH
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYPRESS
MODULE: key.obj (KEY)
ADDRESS: 00C5H
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYLAST
MODULE: key.obj (KEY)
ADDRESS: 00CCH
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: KEYPRESS
MODULE: System.obj (SYSTEM)
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: KEYDOWN
MODULE: System.obj (SYSTEM)
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
SYMBOL: KEYUP
MODULE: System.obj (SYSTEM)
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
SYMBOL: KEYPRESS
MODULE: System.obj (SYSTEM)
ADDRESS: 0115H
Program Size: data=9.0 xdata=0 code=304
"1214" - 0 Error(s), 39 Warning(s).
|