R3EQU0X03PORT5EQU0X05PORT6EQU0X06R3EQU0X03KEY_STATUSEQU0X10;低半字節為按鍵標志,高半字節為控制標志SIGNAL_LOWEQU0X11;信號電平低計數器SIGNAL_HIGHEQU0X12;信號電平高計數器DATA_RECORDEREQU0X1
R3EQU0X03
PORT5EQU0X05
PORT6EQU0X06
R3EQU0X03
KEY_STATUSEQU0X10;低半字節為按鍵標志,高半字節為控制標志
SIGNAL_LOWEQU0X11;信號電平低計數器
SIGNAL_HIGHEQU0X12;信號電平高計數器
DATA_RECORDEREQU0X13;接收碼數據字節
CODE_RECORDER2EQU0X14;接收碼地址高字節
CODE_RECORDER1EQU0X15;接收碼地址低字節
CODE_TOTALEQU0X16;接收數據位計數器
KEY_COUNTEREQU0X17;兩次按鍵檢測計數器
/**********************KEY_STATUS標志位定義***********************************/
AUTORUN_KEYEQU0;遙控鍵標志
LOCK_KEYEQU1;防盜鍵標志
SEARCH_KEYEQU2;尋車鍵標志
OPEN_KEYEQU3;解除鍵標志
PRESS_FLAGEQU4;有鍵按下標志
CHECK_FLAGEQU5;校驗標志
/***********************CONSTANTDEFINE*************************************/
CODE_ADDRESS1EQU0B10001100;遙控器地址碼,更改常數即可實現其他遙控器收碼
CODE_ADDRESS2EQU0B00101100
AUTORUN_VALUEEQU0B00000011;遙控器相應鍵值,改變相應數值即可更改其功能
LOCK_VALUEEQU0B00001100
SEARCH_VALUEEQU0B00110000
OPEN_VALUEEQU0B11000000
/**********************當PORT6.2口電平為高時調用該程序收碼******************/
;PORT6.2為信號輸入口
collect_2262:
MOV a,@0xf0
AndKEY_STATUS,a
clrcode_total
clrsignal_high
collect1:
incsignal_high
MOV A,SIGNAL_HIGH
SUBA,@30
JBSR3,0
RET
clrsignal_low
calldelay20us
jbsport6,2
jmpcollect_low
jmpcollect1
collect_low:
MOV a,signal_high;信號高電平寬度《80US時濾除
suba,@4
jbcr3,0
ret
MOV a,@20;信號高電平寬度在80—400US時為采集為0
suba,signal_high;信號高電平寬度在400US以上時為采集為1
rrcdata_recorder
rrccode_recorder2
rrccode_recorder1
inccode_total
clrsignal_high
MOV a,@24
xora,code_total
jbcr3,2
jmpcollect_end
input_low:
incsignal_low
MOV a,signal_low;信號低電平寬度大于800US時濾除
suba,@40
jbsr3,0
ret
calldelay20us
jbsport6,2;3
jmpinput_low
jmpcollect1
collect_end:
MOV a,code_recorder1;校驗低字節地址
xora,@code_address1
jbsr3,2
ret
MOV a,code_recorder2;校驗高字節地址
xora,@code_address2
jbsr3,2
ret
jbsKEY_STATUS,check_flag;是否是第一串收碼?
jmpstorage_data
bcKEY_STATUS,check_flag
MOV a,com_data_rec
xora,data_recorder
jbsr3,2
jmpstorage_data
MOV a,data_recorder
xora,@autorun_value;是啟動鍵?
jbsr3,2
jmpkey1
bsKEY_STATUS,autorun_key;置啟動鍵標志
bsKEY_STATUS,press_flag;置有鍵按下標志
clrkey_counter;清除按鍵間隔計數器
ret
key1:
MOV a,data_recorder
xora,@open_value;是解除鍵?
jbsr3,2
jmpkey2
bsKEY_STATUS,open_key
bsKEY_STATUS,press_flag
clrkey_counter
ret
key2:
MOV a,data_recorder
anda,@0x0c;同時有兩個鍵按下時不為0X30
xora,@lock_value;是防盜鍵?
jbsr3,2
jmpkey3
bsKEY_STATUS,lock_key
bsKEY_STATUS,press_flag
clrkey_counter
key3:
MOV a,data_recorder
anda,@0x30
xora,@search_value;是尋車鍵?
jbsr3,2
ret
bsKEY_STATUS,search_key
bsKEY_STATUS,press_flag
clrkey_counter
ret
storage_data:;第一次收碼存儲數據字節
bsKEY_STATUS,check_flag
MOV a,data_recorder
MOV com_data_rec,a
ret
delay20us:
wdtc
MOV a,@3;9
MOV delay1,a
delay20us_1:
nop
djzdelay1
jmpdelay20us_1
ret