org
00h
sjmp
start
org
01bh
mov
th1,#1eh
mov
tl1,#0ch
cpl
p1.1
inc
r2
mov
a,r2
anl
a,#11b
jnz
exit
cpl
p1.0
exit:reti
start:
setb
ea
setb
et1
setb
tr1
sjmp
$
unsigned char n;
sbit Gate1=P1^0;
sbit Gate2=P1^1;
main()
{
n=0;
TH1=0xff;
TL1=0x05; //定时器250us产生一次中断
MOD = 0x10; //定时器1工作于模式1,(用工作于模式2也可以,而且更 简便)
TR1=1; //使能定时器1
ET0=1; //开中断
EA=1; //开全局中断
while(1)
{;}
}
void Timer(void) interrupt 3
{
TH1=0xff;
TL1=0x05; //定时器250us产生一次中断
Gate2=!Gate2; //产生500us方波
n++;
if(n==4)
{
n=0;
Gate1=!Gate1; //产生2ms方波
}
}