本帖最后由 madswan 于 2013-3-12 16:09 编辑
我原来的程序前面是这样的:
#include "STC15.H"
#include "intrins.h"
//#include "LQ12864.h"
#include "codetab.h"
#define On 1
#define Off 0
unsigned char Led_TimeCount ;
unsigned char Timer0_5Ms ;
unsigned char TIME_MM;
unsigned char TIME_SS;
unsigned char TIME_MM1;
unsigned char TIME_SS1 ;//预设时间值
sbit Led = P3^5 ; //用于秒闪烁
sbit Relay = P3^4 ; //用于继电器吸合及释放
bit Timer0_1S_Flag ;
/*******************************************************************/
void Timer0_Init(void) //5毫秒@12.000MHz
{
AUXR |= 0x80; //定时器时钟1T模式
TMOD &= 0xF0; //设置定时器模式( 16位自动重装 )
TL0 = 0xA0; //设置定时初值
TH0 = 0x15; //设置定时初值
TF0 = 0; //清除TF0标志
TR0 = 1; //定时器0开始计时
ET0 = 1;
EA = 1;
TIME_MM=12;
TIME_SS=45;
}
void Timer0_Isr(void) interrupt 1 using 0
{
if ( ++Timer0_5Ms>= 200 )
{
Timer0_5Ms = 0 ;
Timer0_1S_Flag = 1 ;
Led = On ;
}
if ( Led )
{
Led_TimeCount++ ;
if ( Led_TimeCount >=10 )
{
Led_TimeCount = 0 ;
Led = Off ;
}
}
}
void main (void)
{
unsigned int Second ;
unsigned char Hour ;
unsigned char Relay_TimeCount ;
Relay = Led = Off ;
Timer0_Init();
while(1)
{
if ( Timer0_1S_Flag )
{
Timer0_1S_Flag = 0 ;
if ( Relay ) //如果继电器打开
{
Relay_TimeCount++ ;
if ( Relay_TimeCount >= 3 )
{
Relay_TimeCount = 0 ;
Relay = Off ;
}
}
if ( ++Second>=3600 ) //如果满1小时
{
Second = 0 ;
Hour++;
if ( Hour >= 9 )
{
Hour = 0 ;
Relay = On ;
}
}
}
}
}
把“#include"LQ12864.h"屏蔽掉,程序编译通过,无错误和警告;
把这句#include加上之后(LQ12864.h是一个OLED屏幕的驱动),就编译不过了
出现如下一串错误
clock.c(31): error C202: 'TIME_MM': undefined identifier
clock.c(32): error C202: 'TIME_SS': undefined identifier
clock.c(37): error C202: 'Timer0_5Ms': undefined identifier
clock.c(39): error C202: 'Timer0_5Ms': undefined identifier
clock.c(40): error C202: 'Timer0_1S_Flag': undefined identifier
clock.c(41): error C202: 'Led': undefined identifier
clock.c(43): error C202: 'Led': undefined identifier
clock.c(45): error C202: 'Led_TimeCount': undefined identifier
clock.c(46): error C202: 'Led_TimeCount': undefined identifier
clock.c(48): error C202: 'Led_TimeCount': undefined identifier
clock.c(49): error C202: 'Led': undefined identifier
clock.c(59): error C202: 'Relay': undefined identifier
clock.c(63): error C202: 'Timer0_1S_Flag': undefined identifier
clock.c(65): error C202: 'Timer0_1S_Flag': undefined identifier
clock.c(66): error C202: 'Relay': undefined identifier
clock.c(72): error C202: 'Relay': undefined identifier
clock.c(82): error C202: 'Relay': undefined identifier
Target not created
照理这些都在开头定义了的,而且去掉LQ12864.H编译是能通过的,求原因
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>