rlf TMP1,f ; for 10’s of PWR_ON_DELAY
rlf TMP1,f
rlf TMP1,f
MOVfw TMP2
addwf TMP1,f
addwf TMP1,f
learn_2
call ir_chk1 ; wait for high level at IR_C_out, timeout if idle for > 5s
call rc5_rx ; call rc5_rx subroutine
btfsc RC5_Flag ; RC5 code OK?
goto learn_2 ; no, try again
MOVfw RC5_CMD ; check if toggle bit has changed
subwf RC5_CMD_TMP,w ;
btfsc status,z ;
goto learn_2 ; no, try again
MOVfw RC5_CMD ; copy RC5_CMD to w and
andlw b’01111111’ ; clear toggle bit
MOVwf TMP2 ; copy to TMP2
bsf status,c ; check if command is 0...9
sublw d’9’ ;
btfss status,c ;
goto learn_2 ; no, try again
MOVfw TMP1 ; add 10’s and 1’s
addwf TMP2,w ;
MOVwf EEDATA_TMP ; copy to EEDATA_TMP
MOVlw h’00’ ; set EEADR_TMP to h’00’
MOVwf EEADR_TMP ;
call write_ee ; and write to EEPROM
LED_grn ; turn on green LED for 250ms if a
call delay_t6 ; valid code has been received
LED_off
MOVfw RC5_CMD ; copy RC5_CMD to temporary register
MOVwf RC5_CMD_TMP ; for the next toggle bit comparison
learn_3
call ir_chk1 ; wait for high level at IR_C_out, timeout if idle for > 5s
call rc5_rx ; call rc5_rx subroutine
btfsc RC5_Flag ; RC5 code OK?
goto learn_3 ; no, try again
MOVfw RC5_CMD ; check if toggle bit has changed
subwf RC5_CMD_TMP,w ;
btfsc status,z ;
goto learn_3 ; no, try again
MOVfw RC5_CMD ; copy RC5_CMD to w and
andlw b’01111111’ ; clear toggle bit
bcf status,c ; check if command is 0...9
sublw d’9’ ; which can not be assigned
btfsc status,c ; as pwr_key
goto learn_3 ; yes, try again
MOVfw RC5_ADR
MOVwf EEDATA_TMP ; copy to EEDATA_TMP
MOVlw h’01’ ; set EEADR_TMP to h’01’
MOVwf EEADR_TMP ;
call write_ee ; and write to EEPROM
MOVfw RC5_CMD ; copy RC5_CMD to w and
andlw b’01111111’ ; clear toggle bit
MOVwf EEDATA_TMP ; copy to EEDATA_TMP
MOVlw h’02’ ; set EEADR_TMP to h’02’
MOVwf EEADR_TMP ;
call write_ee ; and write to EEPROM
call copy_ee ; copy new values to RAM
LED_grn ; turn on green LED for 250ms to indicate
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] 下一页
本文关键字:程序 PIC单片机,单片机-工控设备 - PIC单片机