您当前的位置:五五电子网电子知识单片机-工控设备PIC单片机PIC16F628红外接收程序 正文
PIC16F628红外接收程序

PIC16F628红外接收程序

点击数:7626 次   录入时间:03-04 11:44:18   整理:http://www.55dianzi.com   PIC单片机
    MOVfw    KEYCOUNT    ;
    sublw    TurnOnDelay    ; if reached TurnOnDelay, activate PWRout
    btfss    status,z
    goto    cont
    bsf    PWRout        ; activate PWRout for 250ms
    call    delay_t6
    bcf    PWRout
    goto    boot_delay    ; and goto boot_delay

no_match
    clrf    KEYCOUNT    ; clear KEYCOUNT

cont
    MOVfw    RC5_CMD        ; copy RC5_CMD to temporary register
    MOVwf    RC5_CMD_TMP    ; for next toggle bit comparison

zero_key            ; check if 0 key on remote control is pressed
                ; at least 44 * 114ms (RC5 code repetition rate) = approx. 5s
    MOVfw    RC5_CMD        ; load RC5_CMD into w
    andlw    b’01111111’    ; and clear toggle bit
    btfss    status,z    ; does O key (command ’0000000’, any address) match?
    goto    no_match_1    ;

    MOVfw    RC5_CMD_TMP_1    ; toggle bit also unchanged?
    subwf    RC5_CMD,w    ;
    btfss    status,z    ;
    goto    no_match_1    ; - no, has changed
    incf    KEYCOUNT_1,f    ; - yes, unchanged, increment KEYCOUNT_1
    MOVfw    KEYCOUNT_1    ;
    sublw    d’44’        ;
    btfss    status,z    ; reached 44 (approx. 5s)?
    goto    cont_1        ; - no, loop
    goto    pgm_or_reboot    ; - yes, goto pgm_or_reboot

no_match_1
    clrf    KEYCOUNT_1    ; clear KEYCOUNT_1

cont_1
    MOVfw    RC5_CMD        ; copy RC5_CMD to temporary register
    MOVwf    RC5_CMD_TMP_1    ; for next toggle bit comparison

    goto    main_loop

pgm_or_reboot
    btfss    ATX_C_out
    goto    pgm_mode    ; PC is in standby --> enable program mode

    LED_red            ; turn LED red to inDICate that reboot has been initialized

    MOVlw    h’1f’        ; set address to h’1f’
    MOVwf    RC5_TX_2    ;
    MOVlw    h’3f’        ; set command to h’3f’
    MOVwf    RC5_TX_1    ; This combination is not used by the remote control. Suitable
                ; entries in lircd.conf and lircrc call a reboot script via irexec

    call    rc5_tx
    bsf    Reboot_Flag    ; set Reboot_flag so that additional delay for green LED flashing
    goto    boot_delay      ; will be added and goto boot_delay

; ------------------------------------------------------------------------------------------------

pwr_sw_1            ; checks if pwr switch of PC is pressed for less or more than
                ; 5 seconds: if less --> power on/off, if more --> reset

    call    delay_t4    ; 50ms delay
    btfsc    PWRin        ; still low after 50ms?
    goto    main_loop    ; if not, assume spike and goto main_loop

    btfss    ATX_C_out    ; ATX on or standby?
    goto    turn_on            ; standby, a reset would be quite useless, so turn on VDR

    clrf    tmr1h        ; clear timer1 registers
    clrf    tmr1l           ;
    MOVlw    d’19’           ; set COUNT to d’19’, this makes approx. 19 * 262ms = 5 seconds
    MOVwf    COUNT           ;

上一页  [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11]  下一页


本文关键字:程序  PIC单片机单片机-工控设备 - PIC单片机