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
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)