Hi I searched in piclist & in google but I couldn’t find any rc5 routine.
Sony of course ok it has same pulse gap after each bit (600mS). But when it comes to RC5 (bi phase) it’s hard for me to write a code because it doesn’t have the same pulse gap.
The below RC5 code written same as Sony (SIRC) thinking it has same pulse gap. But it doesn’t work for Philips remotes.
Does anybody have RC5 code to share for PIC 16F series using assembly?
Many thanks
Sony of course ok it has same pulse gap after each bit (600mS). But when it comes to RC5 (bi phase) it’s hard for me to write a code because it doesn’t have the same pulse gap.
The below RC5 code written same as Sony (SIRC) thinking it has same pulse gap. But it doesn’t work for Philips remotes.
Does anybody have RC5 code to share for PIC 16F series using assembly?
Many thanks
Code:
;======================================
; READ RC5 Format
; OUTPUT : TOGGLE.7 = TOGGLE BIT
; ADDR = ADDRESS 5 BIT
; CDM = COMMAND 6 BIT
; C = 0 READ OK
; = 1 READ ERROR
;======================================
GET_RC5:BTFSC IR
GOTO GET_RC5 ; WAIT IR LOW
CLRF TMR0 ; clear timer 0
NOP
BCF INTCON,T0IF ; CLR timer 0 flag
NOP
;
BTFSC INTCON,T0IF
GOTO ERR1
;
BTFSS IR
GOTO $-3
;
MOVF TMR0,W
;MOVLW 0xC8 ; FOR TEST
MOVWF TEMP
MOVLW 0XFF ; 1020 mS = 255*4
SUBWF TEMP,W
BTFSC STATUS,C
GOTO ERR1 ; ERROR IF Time > 1020 uS
MOVLW 0XC8 ; 800 mS
SUBWF TEMP,W
BTFSS STATUS,C
GOTO ERR1 ; ERROR IF Time < 800 uS (C8h * TM0 Prescaler = 800 uS )
;
BTFSC IR ; Time validate 800uS-1020uS
GOTO $-1 ; WAIT TO LOW (Syn BIT)
CALL DELAY1252 ; DELAY 3/4 BIT LENGHT=1252 uS
;
BTFSS IR
BCF TOGGLE,7
BTFSC IR
BSF TOGGLE,7
;
BTFSS IR
GOTO $+4
BTFSC IR
GOTO $-1
GOTO READ
;
BTFSS IR
GOTO $-1
;====== READ ADDRESS 5 BIT ===========
; READ MSB FIRST
;
READ: [COLOR="Red"]MOVLW 5
MOVWF TEMP ; LOOP COUNTER
CLRF ADDR[/COLOR]
;
READ1: CALL DELAY1252
BTFSS IR
BCF STATUS,C
BTFSC IR
BSF STATUS,C
RLF ADDR,F ; SHIFT LEFT ADDRESS
;
BTFSS IR
GOTO $+4
BTFSC IR ; WAIT LOW
GOTO $-1
GOTO $+3
;
BTFSS IR
GOTO $-1
;
DECFSZ TEMP,F
GOTO READ1
;
;====== READ COMMAND 6 BIT ===========
; READ MSB FIRST
;
[COLOR="Red"]MOVLW 6
MOVWF TEMP ; LOOP COUNTER
CLRF CMD[/COLOR]
;
CMD1: CALL DELAY1252
BTFSS IR
BCF STATUS,C
BTFSC IR
BSF STATUS,C
RLF CMD,F ; SHIFT LEFT COMMAND
;
BTFSS IR
GOTO $+4
BTFSC IR
GOTO $-1
GOTO $+3
;
BTFSS IR
GOTO $-1
;
DECFSZ TEMP,F
GOTO CMD1
;
MOVLW 0X3F ; 0011 1111
ANDWF CMD,F
MOVLW 0X1F ; 0001 1111
ANDWF ADDR,F
BCF STATUS,C ; C=0 NO ERROR
RETURN
;
ERR1: BSF STATUS,C ; C=1 HAVE ERROR
RETURN