#in
用2个8421编码开关和stc15w201s做的9.9秒延时开关,下列程序不能正常运作,求各位指教
#include<reg52.h>
sbit timeup = P1^4; //延时完结输出
sbit flash = P1^5; //运行闪灯
unsigned char tt, nn, time;
void delay(unsigned char x)
{ unsigned char i, j; for(i = 0;i <= x; i++) for(j = 0; j <= 50; j++); }
void main()
{ unsigned char x, y,
timeup = 1;
TMOD = 0x01;
TR0 = 1;
IE = 0x82;
nn = 255;
time = 0;
TH0 = 0x3C;
TL0 = 0xB0;
x = P1;
x = ~x;
y = P3;
y = ~y;
time = y % 16 * 10 + x % 16;
while (1)
{ flash=0; delay(300); flash=1; delay(300); }
}
void b() interrupt 1
{ TH0 = 0x3C;
TL0 = 0xB0;
tt++;
if (tt == 10)
{
tt = 0; nn++;
if (nn == time)
{ TR0 = 0; timeup = 0;}
}
}
|