R3EQU0X03PORT5EQU0X05PORT6EQU0X06R3EQU0X03KEY_STATUSEQU0X10;低半字節(jié)為按鍵標(biāo)志,高半字節(jié)為控制標(biāo)志SIGNAL_LOWEQU0X11;信號(hào)電平低計(jì)數(shù)器SIGNAL_HIGHEQU0X12;信號(hào)電平高計(jì)數(shù)器DATA_RECORDEREQU0X1
R3EQU0X03
PORT5EQU0X05
PORT6EQU0X06
R3EQU0X03
KEY_STATUSEQU0X10;低半字節(jié)為按鍵標(biāo)志,高半字節(jié)為控制標(biāo)志
SIGNAL_LOWEQU0X11;信號(hào)電平低計(jì)數(shù)器
SIGNAL_HIGHEQU0X12;信號(hào)電平高計(jì)數(shù)器
DATA_RECORDEREQU0X13;接收碼數(shù)據(jù)字節(jié)
CODE_RECORDER2EQU0X14;接收碼地址高字節(jié)
CODE_RECORDER1EQU0X15;接收碼地址低字節(jié)
CODE_TOTALEQU0X16;接收數(shù)據(jù)位計(jì)數(shù)器
KEY_COUNTEREQU0X17;兩次按鍵檢測(cè)計(jì)數(shù)器
/**********************KEY_STATUS標(biāo)志位定義***********************************/
AUTORUN_KEYEQU0;遙控鍵標(biāo)志
LOCK_KEYEQU1;防盜鍵標(biāo)志
SEARCH_KEYEQU2;尋車(chē)鍵標(biāo)志
OPEN_KEYEQU3;解除鍵標(biāo)志
PRESS_FLAGEQU4;有鍵按下標(biāo)志
CHECK_FLAGEQU5;校驗(yàn)標(biāo)志
/***********************CONSTANTDEFINE*************************************/
CODE_ADDRESS1EQU0B10001100;遙控器地址碼,更改常數(shù)即可實(shí)現(xiàn)其他遙控器收碼
CODE_ADDRESS2EQU0B00101100
AUTORUN_VALUEEQU0B00000011;遙控器相應(yīng)鍵值,改變相應(yīng)數(shù)值即可更改其功能
LOCK_VALUEEQU0B00001100
SEARCH_VALUEEQU0B00110000
OPEN_VALUEEQU0B11000000
/**********************當(dāng)PORT6.2口電平為高時(shí)調(diào)用該程序收碼******************/
;PORT6.2為信號(hào)輸入口
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;信號(hào)高電平寬度《80US時(shí)濾除
suba,@4
jbcr3,0
ret
MOV a,@20;信號(hào)高電平寬度在80—400US時(shí)為采集為0
suba,signal_high;信號(hào)高電平寬度在400US以上時(shí)為采集為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;信號(hào)低電平寬度大于800US時(shí)濾除
suba,@40
jbsr3,0
ret
calldelay20us
jbsport6,2;3
jmpinput_low
jmpcollect1
collect_end:
MOV a,code_recorder1;校驗(yàn)低字節(jié)地址
xora,@code_address1
jbsr3,2
ret
MOV a,code_recorder2;校驗(yàn)高字節(jié)地址
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;是啟動(dòng)鍵?
jbsr3,2
jmpkey1
bsKEY_STATUS,autorun_key;置啟動(dòng)鍵標(biāo)志
bsKEY_STATUS,press_flag;置有鍵按下標(biāo)志
clrkey_counter;清除按鍵間隔計(jì)數(shù)器
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;同時(shí)有兩個(gè)鍵按下時(shí)不為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;是尋車(chē)鍵?
jbsr3,2
ret
bsKEY_STATUS,search_key
bsKEY_STATUS,press_flag
clrkey_counter
ret
storage_data:;第一次收碼存儲(chǔ)數(shù)據(jù)字節(jié)
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