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

PIC16F628红外接收程序

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

PIC16F628红外接收程序
; Some notes on RC5
;
; 14 RC5 bits:
; SSTAAAAACCCCCC
;
; S: 2 start bits, T: 1 toggle bit, A: 5 address bits, C: 6 command bits
;
; Usually both start bits are high. Extended RC5 uses the 2nd start bit for expanding
; the 6 command bits to 7 bits. After receiving a complete 14 bit word, this bit
; is inverted and added as bit 6 to the register ’RC5_CMD’. The toggle bit is
; copied to bit 7 of ’RC5_CMD’. The 5 LSBs of register ’RC5_ADR’ contain the
; 5 address bits; the 3 MSBs are set to 0.
; Result after a valid code has been received:        ;RC5_ADR:000AAAAARC5_CMD:TCCCCCCC
; Note that most IR receiver Chips (e.g. SFH5110-xx) have an active low output, however, the
; PIC’s internal comparator inverts the signal. An inverting driver transistor for the RS232
; interface finally inverts and level shifts the signal again so that the standard LIRC
; configuration (i.e. active low) must be used.
;
;
; PIC16F628 connections
;
; PIN    FUNCTION
;
; RB7    ICSP
; RB6    ICSP
; RA5    ICSP
;
; RB5    测试输出,高电平有效
; RB4    PWRin    -- PC开关输入低电平有效
; RB3   RESETout --输出晶体管重拨 ,高电平有效
; RB2   PWRout   -- 输出晶体管 for MB ATX pwr on/off ,高电平有效
; RB1    LEDgrn   -- 输出 LED 绿管 ,高电平有效
; RB0    LEDred   -- 输出 LED 红管 ,高电平有效
;
; RA7    4.000 MC Crystal
; RA6    4.000 MC crystal
;
; RA4    (unused)
; RA3    comparator C1 output -- transistor base drive for RS232 TX
; RA2    (internally connected to Vref = 1.25 volts)
; RA1    ATXin -- comparator C2 inverting input for sensing -5 volts of ATX power supply
; RA0    IRin  -- comparator C1 inverting input for IR receiver chip
;
;--- Configuration --------------------------------------------------------------------------------
;
; PIC16F628, Power up timer, no watchdog, HS-oscillator, *no* brown out detect, LVP off, CP off,
; MCLRE off, f = 4MHz

    list p=16f628

    __CONFIG    _pwrte_on & _wdt_off & _hs_osc & _boden_off & _lvp_off & _cp_off & _mclre_off

    include        <p16f628.inc>

;--- Variables [all UPPER CASE] -------------------------------------------------------------------

    cbLOCk    h’20’

DATA_1        ; 16-bit shift register for incoming RC5 bits
DATA_2        ;
DATA_TMP1    ; temporary register for RC5 codes
DATA_TMP2    ; temporary register for RC5 codes
BITCOUNT    ; counter for the RC5 bits
COUNT        ; universal temporary count register
TMP        ; universal temporary registers
TMP1        ;
TMP2        ;
RC5_ADR        ; received RC5 address after clean up: ’000AAAAA’
RC5_CMD        ; received RC5 command after clean up: ’0CCCCCCC’
RC5_CMD_TMP    ; temporary register for RC5 command
RC5_CMD_TMP_1    ; temporary register for RC5 command
KEYCOUNT    ; counts the incoming RC5 pwr-key PACkets to set up a delay
KEYCOUNT_1    ; counts the incoming RC5 0-key packets to set up a delay
RC5_TX_1    ; 16-bit shift register for outgoing RC5 bits
RC5_TX_2    ;
EEADR_TMP    ; holds the EEPROM address when calling the EEPROM write subroutine
EEDATA_TMP    ; holds the EEPROM data when calling the EEPROM write subroutine

PWR_ON_DELAY    ; 00...99 (recalled from EEPROM location h’00’)
PWR_KEY_ADR    ; assigned RC5 pwr key address ’000AAAAA’ (recalled from EEPROM location h’01’)
PWR_KEY_CMD    ; assigned RC5 pwr key command ’0CCCCCCC’ (recalled from EEPROM location h’02’)

D1        ; temporary registers for delay routines
D2        ;
D3        ;

FLAGS        ; flags, see definitions

    endc

;--- EEPROM default data --------------------------------------------------------------------------

    org    h’2100’
                        ; adr    content
    de    d’45’                ; h’00’    PWR_ON_DELAY

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


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