pic 16f84A ile asm dilinde RF alıcı- verici yardımmm

gece0

Üye
Katılım
3 Ara 2008
Mesajlar
18
Puanları
1
Yaş
40
Merhaba arkadaşlar 16f84 ile RF alıcı verici yapmak istiyorum udea dan alıcı verici modülleri aldım fakat 16f84 de asm dilinde bunları nasıl konuşturabilirim.
Bu konuda bilgi verirseniz sevinirim..
 
Bilim ve teknik dergisinde çıkan bir yazıdır.
16f84 değil ama 16f628 ile yapılmış ve udea modüller kullanılmış.
 
bilgi için sağol Elek fakat buradaki kodlar C ile yazılmış. Bana assembly ile yazılmış bir program lazım. öğrenmek istediğim konu pic 16f84 de assembler kullanarak seri datayı nasıl alıp verebilirim
 
selam kardeş. istediğin dosyaları gönderiyorum. umarım işine yarar. ben bu devreyi çalıştırmıştım.


;********************************************************
;
; Remote Controller Transmitter
;
; Author : Seiichi Inoue
;********************************************************

list p=pic16f84a
include p16f84a.inc
__config _hs_osc & _wdt_off & _pwrte_on & _cp_off
errorlevel -302 ;Eliminate bank warning


;**************** Label Definition ********************
cblock h'0c'
tx_status ;TX status save area
tx_substatus ;TX substatus save area
pattern ;Pattern save area
endc

ptn1 equ b'11110000' ;Pattern 1 data
ptn2 equ b'00001111' ;Pattern 2 data
ra4 equ d'4' ;RA4 bit position

;**************** Program Start ***********************
org 0 ;Reset Vector
goto init
org 4 ;Interrupt Vector
goto int

;**************** Initial Process *********************
init bsf status,rp0 ;Change to Bank1
movlw b'00000011' ;RA4:OUT RA1,0:IN mode
movwf trisa ;Set TRISA reg
movlw b'00000101' ;RBPU/TOCS/PSA=0,PS=101
movwf option_reg ;Set OPTION_REG
bcf status,rp0 ;Change to Bank0

clrf porta ;Stop wave emission
clrf tx_status ;Clear TX status
clrf tx_substatus ;Clear TX substatus

movlw b'00000001' ;Set mask pattern
andwf porta,w ;Pick up RA0
btfsc status,z ;RA0 = 1 (SW1 ON) ?
goto in1 ;No. Check next input
movlw ptn1 ;Set pattern1 data
in0 movwf pattern ;Save pattern data
goto tm ;Jump to timer set
in1 movlw b'00000010' ;Set mask pattern
andwf porta,w ;Pick up RA1
btfsc status,z ;RA1 = 1 (SW2 ON) ?
goto init ;No. Illegal input
movlw ptn2 ;Set pattern2 data
goto in0 ;Jump to pattern save

tm movlw d'100' ;256-10000us/64us = 100
movwf tmr0 ;Set 10msec to TMR0
movlw h'a0' ;GIE=1,TOIE=1
movwf intcon ;Interruption enable

goto $ ;Wait interruption

;********* Begin Timer Interruption Process ***********
int
bcf intcon,t0if ;Clear timer int flag

stchk0
movf tx_status,w ;Read TX status
btfss status,z ;TX status = 0 ?
goto stchk1 ;No. Next

;************ Preamble data send Process **************
movlw d'7' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfsc status,z ;Substatus = 7 ?
goto stinc ;Yes. Substatus + 1
movlw d'8' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfsc status,z ;Substatus = 8 ?
goto st01 ;Yes.
movlw d'9' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfsc status,z ;Substatus = 9 ?
goto st02 ;Yes.
movlw b'00000001' ;Set mask pattern
andwf tx_substatus,w ;Pick up LSB
btfss status,z ;LSB = 0 (Even) ?
goto st00 ;No. (Odd)
bsf porta,ra4 ;Start wave emission
goto stinc ;Jump to Substatus + 1
st00 bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1
st01 bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1
st02 bsf porta,ra4 ;Start wave emission
clrf tx_substatus ;Clear TX substatus
incf tx_status,f ;Set TX status = 1
goto int_end ;Jump to timer int end

;********************************************************
stchk1
movlw d'1' ;Set check data
subwf tx_status,w ;TX status - check data
btfss status,z ;TX status = 1 ?
goto stchk2 ;No. Next

;************ Control data send Process ***************
movf tx_substatus,w ;Read TX substatus
btfss status,z ;Substatus = 0 ?
goto st11 ;No. Next
movlw b'00000001' ;Set mask pattern
andwf pattern,w ;Pick up data
btfss status,z ;Data = 0 ?
goto st10 ;No. Data = 1
bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1
st10 bsf porta,ra4 ;Start wave emission
goto stinc ;Jump to Substatus + 1

st11 movlw d'1' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 1 ?
goto st12 ;No. Next
bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1

st12 movlw d'2' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 2 ?
goto st13 ;No. Next
bsf porta,ra4 ;Start wave emission
goto stinc ;Jump to Substatus + 1

st13 movlw d'3' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 3 ?
goto st15 ;No. Next
movlw b'00000010' ;Set mask pattern
andwf pattern,w ;Pick up data
btfss status,z ;Data = 0 ?
goto st14 ;No. Data = 1
bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1
st14 bsf porta,ra4 ;Start wave emission
goto stinc ;Jump to Substatus + 1

st15 movlw d'4' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 4 ?
goto st16 ;No. Next
bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1

st16 movlw d'5' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 5 ?
goto st17 ;No. Next
bsf porta,ra4 ;Start wave emission
goto stinc ;Jump to Substatus + 1

st17 movlw d'6' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 6 ?
goto st19 ;No. Next
movlw b'00000100' ;Set mask pattern
andwf pattern,w ;Pick up data
btfss status,z ;Data = 0 ?
goto st18 ;No. Data = 1
bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1
st18 bsf porta,ra4 ;Start wave emission
goto stinc ;Jump to Substatus + 1

st19 movlw d'7' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 7 ?
goto st20 ;No. Next
bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1

st20 movlw d'8' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 8 ?
goto st21 ;No. Next
bsf porta,ra4 ;Start wave emission
goto stinc ;Jump to Substatus + 1

st21 movlw d'9' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 9 ?
goto st23 ;No. Next
movlw b'00001000' ;Set mask pattern
andwf pattern,w ;Pick up data
btfss status,z ;Data = 0 ?
goto st22 ;No. Data = 1
bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1
st22 bsf porta,ra4 ;Start wave emission
goto stinc ;Jump to Substatus + 1

st23 movlw d'10' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 10 ?
goto st24 ;No. Next
bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1

st24 movlw d'11' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 11 ?
goto st25 ;No. Next
bsf porta,ra4 ;Start wave emission
goto stinc ;Jump to Substatus + 1

st25 movlw d'12' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 12 ?
goto st27 ;No. Next
movlw b'00010000' ;Set mask pattern
andwf pattern,w ;Pick up data
btfss status,z ;Data = 0 ?
goto st26 ;No. Data = 1
bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1
st26 bsf porta,ra4 ;Start wave emission
goto stinc ;Jump to Substatus + 1

st27 movlw d'13' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 13 ?
goto st28 ;No. Next
bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1

st28 movlw d'14' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 14 ?
goto st29 ;No. Next
bsf porta,ra4 ;Start wave emission
goto stinc ;Jump to Substatus + 1

st29 movlw d'15' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 15 ?
goto st31 ;No. Next
movlw b'00100000' ;Set mask pattern
andwf pattern,w ;Pick up data
btfss status,z ;Data = 0 ?
goto st30 ;No. Data = 1
bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1
st30 bsf porta,ra4 ;Start wave emission
goto stinc ;Jump to Substatus + 1

st31 movlw d'16' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 16 ?
goto st32 ;No. Next
bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1

st32 movlw d'17' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 17 ?
goto st33 ;No. Next
bsf porta,ra4 ;Start wave emission
goto stinc ;Jump to Substatus + 1

st33 movlw d'18' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 18 ?
goto st35 ;No. Next
movlw b'01000000' ;Set mask pattern
andwf pattern,w ;Pick up data
btfss status,z ;Data = 0 ?
goto st34 ;No. Data = 1
bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1
st34 bsf porta,ra4 ;Start wave emission
goto stinc ;Jump to Substatus + 1

st35 movlw d'19' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 19 ?
goto st36 ;No. Next
bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1

st36 movlw d'20' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 20 ?
goto st37 ;No. Next
bsf porta,ra4 ;Start wave emission
goto stinc ;Jump to Substatus + 1

st37 movlw d'21' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 21 ?
goto st39 ;No. Next
movlw b'10000000' ;Set mask pattern
andwf pattern,w ;Pick up data
btfss status,z ;Data = 0 ?
goto st38 ;No. Data = 1
bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1
st38 bsf porta,ra4 ;Start wave emission
goto stinc ;Jump to Substatus + 1

st39 movlw d'22' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 22 ?
goto st40 ;No. Next
bcf porta,ra4 ;Stop wave emission
goto stinc ;Jump to Substatus + 1

st40 bsf porta,ra4 ;Start wave emission
clrf tx_substatus ;Clear TX substatus
incf tx_status,f ;Set TX status = 2
goto int_end ;Jump to timer int end

;************** End data send Process *****************
stchk2 movlw d'2' ;Set check data
subwf tx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 2 ?
goto stinc ;No.Jump to Substatus + 1
bcf porta,ra4 ;Stop wave emission
clrf tx_substatus ;Clear TX substatus
clrf tx_status ;Clear TX status
goto int_end ;Jump to timer int end

;*********** Substatus Increment Process **************
stinc incf tx_substatus,f ;Substatus + 1

;******** End of Timer Interruption Process ***********
int_end movlw d'100' ;256-10000us/64us = 100
movwf tmr0 ;Set 10msec to TMR0
retfie ;End of interruption

;********************************************************
; END of Remote Controller Transmitter
;********************************************************

end






;********************************************************
;
; Remote Controller Receiver
;
; Author : Seiichi Inoue
;********************************************************

list p=pic16f84a
include p16f84a.inc
__config _hs_osc & _wdt_off & _pwrte_on & _cp_off
errorlevel -302 ;Eliminate bank warning


;**************** Label Definition ********************
cblock h'0c'
rx_status ;RX status save area
rx_substatus ;RX substatus save area
rx_edge ;Input edge check flag
last_look ;Input last look flag
code_ck ;Code check flag
cont_data ;Control Data
relay ;Relay ON counter
w_save ;W reg save area
s_save ;Status reg save area
endc

ptn1 equ b'11110000' ;Pattern 1 data
ptn2 equ b'00001111' ;Pattern 2 data
ra1 equ d'1' ;RA1 bit position
rb5 equ d'5' ;RB5 bit position
rb7 equ d'7' ;RB7 bit position

;**************** Program Start ***********************
org 0 ;Reset Vector
goto init
org 4 ;Interrupt Vector
goto int

;****************** Initial Process *******************
init bsf status,rp0 ;Change to Bank1
movlw b'00011111' ;RA4-0:IN mode
movwf trisa ;Set TRISA reg
movlw b'00000000' ;RB7-0:OUT mode
movwf trisb ;Set TRISB reg
movlw b'00000101' ;RBPU/TOCS/PSA=0,PS=101
movwf option_reg ;Set OPTION_REG
bcf status,rp0 ;Change to Bank0

clrf portb ;RL1,RL2 OFF
clrf rx_status ;Clear RX status
clrf rx_substatus ;Clear RX substatus
clrf rx_edge ;Clear Edge check flag
incf last_look,f ;Set Last Look flag ON
clrf code_ck ;Clear code check flag
clrf cont_data ;Clear Control Data
clrf relay ;Clear Relay ON counter
movlw d'100' ;256-10000us/64us = 100
movwf tmr0 ;Set 10msec to TMR0
movlw h'a0' ;GIE=1,TOIE=1
movwf intcon ;Interruption enable

;*********** Initial Input check Process **************
edge_check
btfss porta,ra1 ;Input signal ON ?
goto check1 ;No. Signal OFF
btfsc last_look,0 ;Last Look flag OFF ?
goto edge_check ;No. Input NOT changed
bcf intcon,gie ;Interruption disable
incf code_ck,f ;Set code check flag ON
incf last_look,f ;Set Last Look flag ON
movlw d'178' ;256-5000us/64us = 178
movwf tmr0 ;Set 5msec to TMR0
bsf intcon,gie ;Interruption enable
wait
btfss rx_edge,0 ;Input edge check ?
goto wait ;No. Wait interruption
clrf rx_edge ;Clear edge check flag
goto edge_check ;Jump to Input edge check
check1
clrf last_look ;Set Last Look flag OFF
goto edge_check ;Jump to Input edge check

;************ Timer Interruption Process **************
int
movwf w_save ;Save W register
movf status,w ;Read STATUS reg
movwf s_save ;Save STATUS reg
bcf status,rp0 ;Change to Bank0
bcf intcon,t0if ;Clear timer int flag

movf relay,w ;Read Relay ON counter
btfsc status,z ;Counter = 0 ?
goto stchk0 ;Yes
decfsz relay,f ;Counter - 1 = 0 ?
goto stchk0 ;No
clrf portb ;Relay OFF

stchk0
movf code_ck,w ;Read code check flag
btfsc status,z ;Flag ON ?
goto int_end ;No. End of interruption
movf rx_status,w ;Read RX status
btfss status,z ;Status = 0 ?
goto stchk1 ;No. Next

;*********** Preamble data check Process *************
movf rx_substatus,w ;Read RX substatus
btfss status,z ;Substatus = 0 ?
goto st00 ;No. Next
goto st_on ;Input signal ON ?
st00 movlw d'1' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 1 ?
goto st01 ;No.
goto st_off ;Input signal OFF ?
st01 movlw d'2' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 2 ?
goto st02 ;No.
goto st_on ;Input signal ON ?
st02 movlw d'3' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 3 ?
goto st03 ;No.
goto st_off ;Input signal OFF ?
st03 movlw d'4' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 4 ?
goto st04 ;No.
goto st_on ;Input signal ON ?
st04 movlw d'5' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 5 ?
goto st05 ;No.
goto st_off ;Input signal OFF ?
st05 movlw d'6' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 6 ?
goto st06 ;No.
goto st_on ;Input signal ON ?
st06 movlw d'7' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 7 ?
goto st07 ;No. Substatus=8
goto st_on ;Input signal ON ?
st07 btfsc porta,ra1 ;Input signal OFF ?
goto illegal ;No. Jump to illegal
clrf rx_substatus ;RX substatus = 0
incf rx_status,f ;RX status = 1
clrf cont_data ;Clear count data
goto int_end ;End of interruption

;********************************************************
stchk1
movlw d'1' ;Set check data
subwf rx_status,w ;RX status - check data
btfss status,z ;RX status = 1 ?
goto stchk2 ;No. Next

;************ Control data check Process **************
movf rx_substatus,w ;Read RX substatus
btfss status,z ;Substatus = 0 ?
goto st10 ;No. Next
goto st_on ;Input signal ON ?
st10 movlw d'1' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 1 ?
goto st11 ;No.
btfss porta,ra1 ;B0 = 1 ?
goto stinc ;Jump to Substatus + 1
bsf cont_data,0 ;Set B0 = 1
goto stinc ;Jump to Substatus + 1
st11 movlw d'2' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 2 ?
goto st12 ;No.
goto st_off ;Input signal OFF ?
st12 movlw d'3' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 3 ?
goto st13 ;No.
goto st_on ;Input signal ON ?
st13 movlw d'4' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 4 ?
goto st14 ;No.
btfss porta,ra1 ;B1 = 1 ?
goto stinc ;Jump to Substatus + 1
bsf cont_data,1 ;Set B1 = 1
goto stinc ;Jump to Substatus + 1
st14 movlw d'5' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 5 ?
goto st15 ;No.
goto st_off ;Input signal OFF ?
st15 movlw d'6' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 6 ?
goto st16 ;No.
goto st_on ;Input signal ON ?
st16 movlw d'7' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 7 ?
goto st17 ;No.
btfss porta,ra1 ;B2 = 1 ?
goto stinc ;Jump to Substatus + 1
bsf cont_data,2 ;Set B2 = 1
goto stinc ;Jump to Substatus + 1
st17 movlw d'8' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 8 ?
goto st18 ;No.
goto st_off ;Input signal OFF ?
st18 movlw d'9' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 9 ?
goto st19 ;No.
goto st_on ;Input signal ON ?
st19 movlw d'10' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 10 ?
goto st20 ;No.
btfss porta,ra1 ;B3 = 1 ?
goto stinc ;Jump to Substatus + 1
bsf cont_data,3 ;Set B3 = 1
goto stinc ;Jump to Substatus + 1
st20 movlw d'11' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 11 ?
goto st21 ;No.
goto st_off ;Input signal OFF ?
st21 movlw d'12' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 12 ?
goto st22 ;No.
goto st_on ;Input signal ON ?
st22 movlw d'13' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 13 ?
goto st23 ;No.
btfss porta,ra1 ;B4 = 1 ?
goto stinc ;Jump to Substatus + 1
bsf cont_data,4 ;Set B4 = 1
goto stinc ;Jump to Substatus + 1
st23 movlw d'14' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 14 ?
goto st24 ;No.
goto st_off ;Input signal OFF ?
st24 movlw d'15' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 15 ?
goto st25 ;No.
goto st_on ;Input signal ON ?
st25 movlw d'16' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 16 ?
goto st26 ;No.
btfss porta,ra1 ;B5 = 1 ?
goto stinc ;Jump to Substatus + 1
bsf cont_data,5 ;Set B5 = 1
goto stinc ;Jump to Substatus + 1
st26 movlw d'17' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 17 ?
goto st27 ;No.
goto st_off ;Input signal OFF ?
st27 movlw d'18' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 18 ?
goto st28 ;No.
goto st_on ;Input signal ON ?
st28 movlw d'19' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 19 ?
goto st29 ;No.
btfss porta,ra1 ;B6 = 1 ?
goto stinc ;Jump to Substatus + 1
bsf cont_data,6 ;Set B6 = 1
goto stinc ;Jump to Substatus + 1
st29 movlw d'20' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 20 ?
goto st30 ;No.
goto st_off ;Input signal OFF ?
st30 movlw d'21' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 21 ?
goto st31 ;No.
goto st_on ;Input signal ON ?
st31 movlw d'22' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 22 ?
goto st32 ;No. Substatus=23
btfss porta,ra1 ;B7 = 1 ?
goto stinc ;Jump to Substatus + 1
bsf cont_data,7 ;Set B7 = 1
goto stinc ;Jump to Substatus + 1
st32 btfsc porta,ra1 ;Input signal OFF ?
goto illegal ;No. Jump to illegal
clrf rx_substatus ;RX substatus = 0
incf rx_status,f ;RX status = 2
goto int_end ;End of interruption

st_on
btfss porta,ra1 ;Input signal ON ?
goto illegal ;No. Jump to illegal
goto stinc ;Jump to Substatus + 1
st_off
btfsc porta,ra1 ;Input signal OFF ?
goto illegal ;No. Jump to illegal
goto stinc ;Jump to Substatus + 1

;************** End data check Process ****************
stchk2 btfss porta,ra1 ;Input signal ON ?
goto illegal ;No. Jump to illegal
movlw d'2' ;Set check data
subwf rx_substatus,w ;Substatus - check data
btfss status,z ;Substatus = 2 ?
goto stinc ;Jump to Substatus + 1

;**************** Data check Process ******************
movf cont_data,w ;Read control data
xorlw ptn1 ;Check Pattern1
btfss status,z ;Data = Pattern1 ?
goto dtchk0 ;No.
bcf portb,rb7 ;RL2 OFF
bsf portb,rb5 ;RL1 ON
goto dtchk1 ;Jump to ON counter set
dtchk0
movf cont_data,w ;Read control data
xorlw ptn2 ;Check Pattern2
btfss status,z ;Data = Pattern2 ?
goto illegal ;No. Jump to illegal
bcf portb,rb5 ;RL1 OFF
bsf portb,rb7 ;RL2 ON
dtchk1 movlw d'50' ;Set 500msec Relay ON
movwf relay ;Save Relay ON counter

;***************** Illegal Process ********************
illegal incf rx_edge,f ;Edge check flag ON
clrf rx_substatus ;RX substatus = 0
clrf rx_status ;RX status = 0
clrf code_ck ;Clear code check flag
goto int_end ;End of interruption

;*********** Substatus Increment Process **************
stinc incf rx_substatus,f ;Substatus + 1

;******** End of Timer Interruption Process ***********
int_end movlw d'100' ;256-10000us/64us = 100
movwf tmr0 ;Set 10msec to TMR0
movf s_save,w ;Read saved STATUS reg
movwf status ;Recover STATUS reg
swapf w_save,f ;Read saved W register
swapf w_save,w ;Recover W register
retfie ;End of interruption

;********************************************************
; END of Remote Controller Receiver
;********************************************************

end
 
gönderdiğin kodlar için teşekkürler efsanepold. Yanlız bunları aldığın kaynağı veya devre şemasını bildirirsen ii olur.
 

Yeni mesajlar

Forum istatistikleri

Konular
129,800
Mesajlar
930,203
Kullanıcılar
452,597
Son üye
BLacKSTaiNNN

Yeni konular

Geri
Üst