用单片机制作红外线多路遥控器,Infra-red remote controller
关键字:单片机制作红外线多路遥控器
二、
x0 equ #30 x1 equ #60 x2 equ #90 x3 equ #120 x4 equ #150 x5 equ #180 x6 equ #210 x7 equ #240 fz equ #10 sw bit p3.2 bz bit 00h ORG 0000H aJMP START ORG 0013H ;int1入口 aJMP int1 ORG 001bH ;定时器T1入口 aJMP intt1 org 0030h int1: clr ex1 MOV TH1,#3ch ;定时时间约为100ms MOV TL1,#0b0h setb tr1 ;启动T1计时 setb et1 ;允许T1中断 mov th0,#0 mov tl0,#0 setb tr0 reti intt1: clr tr0 mov a,tl0 mov b,x0 acall jspd jb bz,d01 cpl p1.0 jb sw d01 mov a,p1 orl a,#0feH mov p1,a ajmp d09 d01: mov b,x1 acall jspd jb bz,d02 cpl p1.1 jb sw d02 mov a,p1 orl a,#0fdH mov p1,a ajmp d09 d02: mov b,x2 acall jspd jb bz,d03 cpl p1.2 jb sw d03 mov a,p1 orl a,#0fbH mov p1,a ajmp d09 d03: mov b,x3 acall jspd jb bz,d04 cpl p1.3 jb sw d04 mov a,p1 orl a,#07H mov p1,a ajmp d09 d04: mov b,x4 acall jspd jb bz,d05 cpl p1.4 jb sw d05 mov a,p1 orl a,#0efH mov p1,a ajmp d09 d05: mov b,x5 acall jspd jb bz,d06 cpl p1.5 jb sw d06 mov a,p1 orl a,#0dfH mov p1,a ajmp d09 d06: mov b,x6 acall jspd jb bz,d07 cpl p1.6 jb sw d07 mov a,p1 orl a,#0bfH mov p1,a ajmp d09 d07: mov b,x7 acall jspd jb bz,d09 cpl p1.7 jb sw d09 mov a,p1 orl a,#7fH mov p1,a d09: setb ex1 reti jspd: push acc clr bz cjne a,b,jspd1 ajmp jspd5 jspd1: jc jspd2 subb a,r2 ajmp jspd3 jspd2: mov r1,b mov b,a mov a,r1 clr c subb a,b jspd3: cjne a,fz,jspd4 ajmp jspd5 jspd4: jc jspd5 setb bz pop acc ret jspd5: clr bz pop acc ret start: MOV P1,#0FFH mov p3,#0ffh clr it1 ;int1中断为电平触发 SETB EX1 ;允许int1中断 MOV TMOD,#15H ;设置T0为计数方式、T1为计时方式1 setb ea ;开所有中断 xh: nop ajmp xh end
|