AtomSoft
Well-Known Member
Here is my RC-5 Code. It will send all info correctly except for that toggle bit aka control bit. It will always send one cuz i havent coded that in yet lol but this will send the data correctly since i tested it in the logic analyzer. i thought id put the beta online for all to see. The delays are modded to fit with the cycles used before the calling of them. meaning a 7uS delay is not actually 7uS its less since it takes time to get called.
Code:
;******************************************************************************
; *
; Filename: RC-5 Remote *
; Date: Sunday, May 03, 2009 *
; File Version: 001 *
; *
; Author: Jason Lopez *
; Company: AtomSoft *
; *
;******************************************************************************
; *
; Files Required: P18F2525.INC *
; *
;******************************************************************************
LIST P=18F2525 ;directive to define processor
#include <P18F2525.INC> ;processor specific variable definitions
CONFIG OSC = INTIO67, WDT = OFF, LVP = OFF, XINST = OFF
#DEFINE irL LATB
#DEFINE irT TRISB
#DEFINE ir 0
CBLOCK 0x000
EXAMPLE ;example of a variable in access RAM
d1
d2
d3
tmp1
dev
cmd
ENDC
ORG 0x0000
Init:
movlw 0x72
movwf OSCCON
movlw 0x0F
movwf ADCON1
bcf irT,ir
RemoteData:
movlw 0x03
movwf dev
movlw 0x11
movwf cmd
Main:
bsf irL,ir
call SendData
Loop4Ever:
NOP
goto Loop4Ever
;*****************************************
;* Send IR Data *
;* ------------------------------------- *
;* Dev = Address of device *
;* Cmd = Command *
;*****************************************
SendData
call One
call One
call One
movlw 0x10
ANDWF dev, 0
btfss STATUS, Z
call One
btfsc STATUS, Z
call Zero
movlw 0x08
ANDWF dev, 0
btfss STATUS, Z
call One
btfsc STATUS, Z
call Zero
movlw 0x04
ANDWF dev, 0
btfss STATUS, Z
call One
btfsc STATUS, Z
call Zero
movlw 0x02
ANDWF dev, 0
btfss STATUS, Z
call One
btfsc STATUS, Z
call Zero
movlw 0x01
ANDWF dev, 0
btfss STATUS, Z
call One
btfsc STATUS, Z
call Zero
movlw 0x20
ANDWF cmd, 0
btfss STATUS, Z
call One
btfsc STATUS, Z
call Zero
movlw 0x10
ANDWF cmd, 0
btfss STATUS, Z
call One
btfsc STATUS, Z
call Zero
movlw 0x08
ANDWF cmd, 0
btfss STATUS, Z
call One
btfsc STATUS, Z
call Zero
movlw 0x04
ANDWF cmd, 0
btfss STATUS, Z
call One
btfsc STATUS, Z
call Zero
movlw 0x02
ANDWF cmd, 0
btfss STATUS, Z
call One
btfsc STATUS, Z
call Zero
movlw 0x01
ANDWF cmd, 0
btfss STATUS, Z
call One
btfsc STATUS, Z
call Zero
call Delay890uS
return
;***************************************
;Send a Logic 1
;***************************************
One:
bcf irL, ir
call Delay890uS
movlw d'32'
movwf tmp1
loop1:
decfsz tmp1, f
goto $+6
return
bsf irL, ir
call Delay7uS
bcf irL, ir
call Delay21uS
goto loop1
;***************************************
;Send a Logic 0
;***************************************
Zero:
movlw d'32'
movwf tmp1
loop2:
bsf irL, ir
decfsz tmp1, f
goto $+6
goto Zero1
call Delay7uSZ
bcf irL, ir
call Delay21uS
goto $+4
NOP
goto loop2
Zero1:
bcf irL, ir
call Delay890uS
return
;***************************************
;6.95uS 14 Cycles (7 uS) @ 8 Mhz
;***************************************
Delay7uS
goto $+4
goto $+4
goto $+4
goto $+4
NOP
return
Delay7uSZ
goto $+4
goto $+4
NOP
return
;***************************************
;20.85uS 42 Cycles (21 uS) @ 8 Mhz
;***************************************
Delay21uS
movlw 0x09
movwf d1
Delay21uS_0
decfsz d1, f
goto Delay21uS_0
goto $+4
return
;***************************************
;1780 Cycles (890 uS) @ 8 Mhz
;***************************************
Delay890uS
movlw 0x60 ;2
movwf d1
movlw 0x02
movwf d2
Delay890uS_0
decfsz d1, f
goto $+6
decfsz d2, f
goto Delay890uS_0
goto $+4
nop
return
END
Last edited: