keil中已经定义了为什么编译还说未定义?
#include"1602.h"#include"delay.h"sbitRS=P2^4;//定义端口sbitRW=P2^5;sbitEN=P2^6;#defineRS_...
#include "1602.h"
#include "delay.h"
sbit RS = P2^4; //定义端口
sbit RW = P2^5;
sbit EN = P2^6;
#define RS_CLR RS=0
#define RS_SET RS=1
#define RW_CLR RW=0
#define RW_SET RW=1
#define EN_CLR EN=0
#define EN_SET EN=1
#define DataPort P0
/*---------------判忙函数----------------*/
bit LCD_Check_Busy(void)
{
DataPort = 0xFF;
RS_CLR;
RW_SET;
EN_CLR;
_nop_();
EN_SET;
return (bit)(DataPort & 0x80);
}
编译显示:
LCD1602.C(3): error C202: 'P2': undefined identifier
LCD1602.C(4): error C202: 'P2': undefined identifier
LCD1602.C(5): error C202: 'P2': undefined identifier
LCD1602.c(7): warning C317: attempt to redefine macro 'RS_CLR'
LCD1602.C(20): error C202: 'P0': undefined identifier
LCD1602.C(21): error C202: 'RS': undefined identifier
LCD1602.C(22): error C202: 'RW': undefined identifier
LCD1602.C(23): error C202: 'EN': undefined identifier 展开
#include "delay.h"
sbit RS = P2^4; //定义端口
sbit RW = P2^5;
sbit EN = P2^6;
#define RS_CLR RS=0
#define RS_SET RS=1
#define RW_CLR RW=0
#define RW_SET RW=1
#define EN_CLR EN=0
#define EN_SET EN=1
#define DataPort P0
/*---------------判忙函数----------------*/
bit LCD_Check_Busy(void)
{
DataPort = 0xFF;
RS_CLR;
RW_SET;
EN_CLR;
_nop_();
EN_SET;
return (bit)(DataPort & 0x80);
}
编译显示:
LCD1602.C(3): error C202: 'P2': undefined identifier
LCD1602.C(4): error C202: 'P2': undefined identifier
LCD1602.C(5): error C202: 'P2': undefined identifier
LCD1602.c(7): warning C317: attempt to redefine macro 'RS_CLR'
LCD1602.C(20): error C202: 'P0': undefined identifier
LCD1602.C(21): error C202: 'RS': undefined identifier
LCD1602.C(22): error C202: 'RW': undefined identifier
LCD1602.C(23): error C202: 'EN': undefined identifier 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询