📄 2272rx.asm
字号:
;PT2272 Chips Decode by 89c2051 (11.0592MHz) with PT2262 use 3.3M osc
;REM - signal received pin
;RECEIVE - Correct Signal Detector
;ENABLE_DETE - Continuous Push Detector
;3AH,3BH - Timer value
;31H,32H - use for 8 bit address code
;33H,30H - use for 4 bit data code, if least 4 bit use at data (only use 33H)
;Address - 31H.0 and 32H.0
;float - 31H.0=0 32H.0=1
;Bit 1 - 31H.0=1 32H.0=1
;Bit 0 - 31H.0=0 32H.0=0
;Error - 31H.0=1 32H.0=0
;Each time check the signal 3 times, first use REMOTE, 2 and 3 use REMOTES
;Use Timer1 at 16bit, enable interrupt for timer
$MOD51
ORG 0000H
JMP START
ORG 001BH
RETI
START: MOV SP,#5FH
MOV 30H,#00H
MOV 31H,#00H
MOV 32H,#00H
MOV 33H,#00H
MOV P1,#00H
MOV TMOD,#00010000B
MOV IE,#10001000B
RM_LP: ACALL REMOTE
MOV B,33H
ACALL REMOTES
MOV A,33H
CJNE A,B,RM_LP
MOV B,A
ACALL REMOTES
MOV A,33H
CJNE A,B,RM_LP
MOV P1,A
CLR P3.5
ACALL DELAY1S
SETB P3.5
AJMP RM_LP
REMOTE: MOV 3AH,#55 ; Detect Signal within 50ms
REMOTEA: MOV 3BH,#250
REMOTEB: JB P3.7,REMOTE0 ; Have a Signal, jump to REMOTE0
DJNZ 3BH,REMOTEB
DJNZ 3AH,REMOTEA
REMOTE_END_1:
CLR 20H.0
REMOTE_END:
RET
REMOTE0: JB 20H.0,REMOTE_END_1 ; Check Button un-release, return
REMOTES: MOV 34H,#12 ; received 12bit code & find the about 10ms high level "Header Code"
CLR TF1 ; Set the high level timer at 8~12ms and waiting for 8ms low level, Maximum (70ms
MOV TH1,#00H
MOV TL1,#00H
SETB TR1
REMOTE1: MOV 3AH,#50
REMOTE2: MOV 3BH,#25
REMOTE3: JB P3.7,REMOTE1
JB TF1,REMOTE_END
DJNZ 3BH,REMOTE3
DJNZ 3AH,REMOTE2 ; Waiting for signal at high level within 4ms
CLR TF1
MOV TH1,#0F1H
MOV TL1,#0F0H
SETB TR1
REMOTE_4: JB TF1,REMOTE_5 ; If over 12ms is received error, return
JNB P3.7,REMOTE_4
CLR TR1
AJMP REMOTE6
REMOTE_5: AJMP REMOTE_END
REMOTE6: MOV 3AH,#00 ; Waiting 554us for received signal
DJNZ 3AH,$
MOV C,P3.7
MOV A,33H
RLC A
MOV 33H,A ; Store 1st half bit income signal into 33H
MOV A,31H
RLC A
MOV 31H,A ; Store 1st half bit income signal into 31H
CLR TF1
MOV TH1,#0FAH
MOV TL1,#099H
SETB TR1
RM1: JB TF1,REMOTE_END ; Waiting for 1st half bit fall edge, Time limited 1.5ms
JB P3.7,RM1 ; If over 1.5mS, is error return
CLR TR1
CLR TF1
MOV TH1,#0FAH
MOV TL1,#099H
SETB TR1
RM2: JB TF1,REMOTE_END ; Waiting for 2nd half bit rise edge, Time limited 1.5ms
JNB P3.7,RM2 ; If over 1.5mS, is error return
CLR TR1
MOV 3AH,#00 ; Waiting 554us for received signal
DJNZ 3AH,$
MOV C,P3.7
MOV A,30H
RLC A
MOV 30H,A ; Store 2nd half bit income signal into 30H
MOV A,32H
RLC A
MOV 32H,A ; Store 2nd half bit income signal into 32H
CLR TF1
MOV TH1,#0FAH
MOV TL1,#099H
SETB TR1
RM3: JB TF1,RM5 ; Waiting for 2nd half bit fall edge, Time limited 1.5ms
JB P3.7,RM3 ; If over 1.5mS, is error return
CLR TR1
CLR TF1
MOV TH1,#0FAH
MOV TL1,#099H
SETB TR1
RM4: JB TF1,RM5 ; Waiting for 2nd half bit rise edge, Time limited 1.5ms
JNB P3.7,RM4 ; If over 1.5mS, is error return
CLR TR1
DJNZ 34H,REMOTE6 ; Check is not complete received 12 bit signal, if not return to REMOTE6
MOV 34H,#4 ; Put the received signal left shift 4 bit and
AJMP REMOTE7 ; Put 8 bits password into the same location
RM5: AJMP REMOTE_END
REMOTE7: CLR C
MOV A,33H
RLC A
MOV 33H,A
MOV A,31H
RLC A
MOV 31H,A
CLR C
MOV A,30H
RLC A
MOV 30H,A
MOV A,32H
RLC A
MOV 32H,A
DJNZ 34H,REMOTE7 ; Put 4 bits data coding from high 4 bit to low 4 bits
MOV A,33H
SWAP A
MOV 33H,A
MOV A,30H
SWAP A
MOV 30H,A
SETB 20H.0
AJMP REMOTE_END_1
DELAY1S:
MOV R6,#250 ; DELAY 1S
DL2: MOV R7,#250
DL1: DJNZ R7,DL1
DJNZ R6,DL2
RET
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -