第1个回答 2010-01-07
c的,已经验证过了
#include<reg52.h>
#define uchar unsigned char
sbit P10=P1^0;
sbit P11=P1^1;
uchar k=0,s=0;
void timer(void) interrupt 1
{
TH0=0x3c;
TL0=0xB0;
k++;
s++;
if(s==5)
{
P11=~P11;
s=0;
}
if(k==20)
{
P10=~P10;
k=0;
}
}
main()
{
TMOD=0x01;
TH0=0x3c;
TL0=0xb0;
EA=1;
ET0=1;
TR0=1;
while(1);
}
第2个回答 2010-01-07
t2s_counter data 21h
t05s_counter1 data 22h
t05s_counter2 data 23h
org 0000h
ajmp main
org 000bh
ajmp t0_routine
org 30h
main: mov sp,#30h
mov tmod,#22h
mov tl0,#6
mov th0,#6
mov t05s_counter1,#00h
mov t05s_counter2,#00h
mov t2s_counter,#00h
setb et0
setb tr0
setb ea
sjmp $
t0_routine:
push psw
push acc
inc t05s_counter1
mov a,t05s_counter1
cjne a,#250,return
mov t05s_counter1,#00h
inc t05s_counter2
mov a,t05s_counter2
cjne a,#2,return
mov t05s_counter2,#00h
cpl p1.1
inc t2s_counter
mov a,t2s_counter
cjne a,#4,return
mov t2s_counter,#00h
cpl p1.0
return: pop acc
pop psw
reti
end