发表于:2009/3/30 21:14:01
#0楼
请问下面 C 程序什么地方有错误?
谢谢!
/*ch7-1.c定时器试验1-查询方式-高低位等互上闪*/
//==================================================================
#include <reg51.h>
#define LED P2
#define count_M1 50000
#define TH _M1(65636-count_M1)/256
#define TL _M1(65636-count_M1)%256
//====================================================================
main()
{ int i;
IE=0x82;
TMOD=0x01;
LED=0xf0;
while(1)
{ for (i=0;i<5;i++)
{ TH0=TH_M1;
TL0=TL_M1;
TR0=1;
while(TF0==0);
TF0=0;
}
LED= ~LED;
}
}
是第16行 TH0=TH_M1;
17行 TL0=TL_M1;
中的 TH_M1;
TL_M1;
显示错误
还有,如果下面的TH与_M1靠近(TH_M1与下面的距离不同)也会显示这两条(6、7)条错误。
#define TH _M1(65636-count_M1)/256
#define TL _M1(65636-count_M1)%256
请指正,谢谢!
谢谢!
/*ch7-1.c定时器试验1-查询方式-高低位等互上闪*/
//==================================================================
#include <reg51.h>
#define LED P2
#define count_M1 50000
#define TH _M1(65636-count_M1)/256
#define TL _M1(65636-count_M1)%256
//====================================================================
main()
{ int i;
IE=0x82;
TMOD=0x01;
LED=0xf0;
while(1)
{ for (i=0;i<5;i++)
{ TH0=TH_M1;
TL0=TL_M1;
TR0=1;
while(TF0==0);
TF0=0;
}
LED= ~LED;
}
}
是第16行 TH0=TH_M1;
17行 TL0=TL_M1;
中的 TH_M1;
TL_M1;
显示错误
还有,如果下面的TH与_M1靠近(TH_M1与下面的距离不同)也会显示这两条(6、7)条错误。
#define TH _M1(65636-count_M1)/256
#define TL _M1(65636-count_M1)%256
请指正,谢谢!
[此贴子已经被jint于2009-3-31 8:42:00编辑过]