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

PIC16F628红外接收程序

点击数:7626 次   录入时间:03-04 11:44:18   整理:http://www.55dianzi.com   PIC单片机

chk_low
    btfsc    PWRin        ; still low?
    goto    vdr_pwr_down    ; if not, pwr key was pressed < 5s --> turn off VDR

    btfsc    tmr1h,7        ; check timer1 h register bit 7 (set after 262ms)
    goto    dec_cnt1
    goto    chk_low

dec_cnt1
    clrf    tmr1h        ; clear timer1 registers
    clrf    tmr1l
    decfsz    COUNT,f
    goto    chk_low        ; not yet 5s, loop
    goto    reset        ; power key pressed > 5s

turn_on
    bsf    PWRout        ; activate PWRout for 250ms
    call    delay_t6    ;
    bcf    PWRout        ;
    goto    boot_delay    ; and goto boot_delay

reset    bsf    RESETout    ; activate RESETout for 250ms
    call    delay_t6
    bcf    RESETout

boot_delay            ; variable delay from 0 to 127 s while LED is flashing green
    MOVfw    PWR_ON_DELAY    ; and no command is accepted, delay derived from user preset (0..99)
    btfsc    Reboot_Flag     ; add additional time (defined in RebootDelay) if Reboot_Flag is set
    addlw    RebootDelay     ;
    MOVwf    COUNT
    bcf    status,c
    rlf    COUNT        ; multiply COUNT by two as the g_flash routine takes only 0.5s
    sublw    d’0’        ; if COUNT=0 stop immediately
    btfss    status,z
    goto    g_flash
    bcf    Reboot_Flag    ; clear Reboot_Flag
    goto    main_loop

g_flash
    LED_grn
    call    delay_t6
    LED_off
    call    delay_t6

    decfsz    COUNT,f
    goto    g_flash

    goto    main_loop

vdr_pwr_down
    LED_red            ; turn LED red

    MOVlw    h’1f’        ; set RC5 address to h’1f’ and command to h’3e’ and send the code
    MOVwf    RC5_TX_2    ; This combination is not used by the remote control and will
    MOVlw    h’3e’        ; be send to LIRC instead of the remote’s normal pwr key code.
    MOVwf    RC5_TX_1    ; This way exactly *one* command CAN be sent instead of multiple
                ; (autorepeat of RC5 codes) -- VDR would start and immediately
                ; abort the shutdown if the pwr key is pressed a bit too long ...
                ; A corresponding entry must be added to lircd.conf and the
                ; original pwr key code must be reMOVed.
    call    rc5_tx          ;
                ; Flash red LED while checking if a key on the remote control is
                ; pressed (which stops VDR from executing the shutdown script).
                ; If so, the programm returns to the main loop and the LED
                ; turns green again. Otherwise flash LED until ATX is in standby
                ; and finally turn LED red. Note: The remote’s pwr key will be
                ; ignored (also to avoid problem with RC5/repeat and VDR).

    MOVlw    d’57’           ; set COUNT to d’57’ for timeout couter
    MOVwf    COUNT           ; timeout is approx. 2 * 262ms * 57 = 30 seconds

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


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