- #include<p16f84>
- LIST p=16F84
-
- ; initialisation des registres
-
- indf equ h'00'
- tmr0 equ h'01'
- pcl equ h'02'
- status equ h'03'
- fsr equ h'04'
- porta equ h'05'
- portb equ h'06'
- intcon equ h'0B'
- trisa equ h'85'
- trisb equ h'86'
- r_option equ h'81'
-
-
- ; initialisation des variables
-
- cmp1 equ h'0C'
- cmp2 equ h'0D'
- donn equ h'0E'
-
-
- ; initialisation des ports A & B
-
- org h'00'
-
- clrf status
- clrf porta
- clrf portb
- bsf status,5
- movlw b'00011011'
- movwf trisa
- movlw b'00000000'
- movwf trisb
- bcf status,5
- clrf status
- clrf porta
- clrf portb
- movlw h'00'
- movwf intcon
- clrf cmp1
- clrf cmp2
- clrf donn
- bsf porta,2
-
-
- ; debut du programme
-
- test1 btfsc porta,0
- goto test1
-
- bsf portb,1
- bsf portb,2
- bsf portb,3
- bsf portb,4
-
- call tempo2
- btfss porta,0
- bcf portb,3
- btfss porta,0
- bsf donn,3
-
- call tempo1
- btfss porta,0
- bcf portb,2
- btfss porta,0
- bsf donn,2
-
- call tempo1
- btfss porta,0
- bcf portb,1
- btfss porta,0
- bsf donn,1
-
- call tempo1
- btfss porta,0
- bcf portb,4
- btfss porta,0
- bsf donn,4
-
-
- ; envoie au max232 de la trame RS232
-
- bcf porta,2
- call tempo3
- btfsc donn,1
- bsf porta,2
- call tempo3
- btfsc donn,2
- bsf porta,2
- btfss donn,2
- bcf porta,2
- call tempo3
-
- btfsc donn,3
- bsf porta,2
- btfss donn,3
- bcf porta,2
- call tempo3
-
- btfsc donn,4
- bsf porta,2
- btfss donn,4
- bsf porta,2
- call tempo3
- call tempo3
- call tempo3
- call tempo3
- bsf porta,2
-
- goto test1
-
-
- ; sous programmes
-
- ; tempo de 1.78 ms (durée d'un bit à la norme RC5)
-
- tempo1 movlw h'03'
- movwf cmp2
- movlw h'50'
- movwf cmp1
- t1 decfsz cmp1
- goto t1
- decfsz cmp2
- goto t1
- return
-
-
- ; tempo de 17,8 ms (durée des 10 premiers bits qu'on ne regarde pas)
-
- tempo2 movlw h'16'
- movwf cmp2
- movlw h'00'
- movwf cmp1
- t2 decfsz cmp1
- goto t2
- decfsz cmp2
- goto t2
- return
-
-
- ; tempo de 1200 bauds (833 µs, correspond à la vitesse choisie de la liaison RS232)
-
- tempo3 movlw h'0F'
- movwf cmp2
- movlw h'02'
- movwf cmp1
- t3 decfsz cmp1
- goto t3
- decfsz cmp2
- goto t3
- return
-
- end
#include<p16f84>
LIST p=16F84
; initialisation des registres
indf equ h'00'
tmr0 equ h'01'
pcl equ h'02'
status equ h'03'
fsr equ h'04'
porta equ h'05'
portb equ h'06'
intcon equ h'0B'
trisa equ h'85'
trisb equ h'86'
r_option equ h'81'
; initialisation des variables
cmp1 equ h'0C'
cmp2 equ h'0D'
donn equ h'0E'
; initialisation des ports A & B
org h'00'
clrf status
clrf porta
clrf portb
bsf status,5
movlw b'00011011'
movwf trisa
movlw b'00000000'
movwf trisb
bcf status,5
clrf status
clrf porta
clrf portb
movlw h'00'
movwf intcon
clrf cmp1
clrf cmp2
clrf donn
bsf porta,2
; debut du programme
test1 btfsc porta,0
goto test1
bsf portb,1
bsf portb,2
bsf portb,3
bsf portb,4
call tempo2
btfss porta,0
bcf portb,3
btfss porta,0
bsf donn,3
call tempo1
btfss porta,0
bcf portb,2
btfss porta,0
bsf donn,2
call tempo1
btfss porta,0
bcf portb,1
btfss porta,0
bsf donn,1
call tempo1
btfss porta,0
bcf portb,4
btfss porta,0
bsf donn,4
; envoie au max232 de la trame RS232
bcf porta,2
call tempo3
btfsc donn,1
bsf porta,2
call tempo3
btfsc donn,2
bsf porta,2
btfss donn,2
bcf porta,2
call tempo3
btfsc donn,3
bsf porta,2
btfss donn,3
bcf porta,2
call tempo3
btfsc donn,4
bsf porta,2
btfss donn,4
bsf porta,2
call tempo3
call tempo3
call tempo3
call tempo3
bsf porta,2
goto test1
; sous programmes
; tempo de 1.78 ms (durée d'un bit à la norme RC5)
tempo1 movlw h'03'
movwf cmp2
movlw h'50'
movwf cmp1
t1 decfsz cmp1
goto t1
decfsz cmp2
goto t1
return
; tempo de 17,8 ms (durée des 10 premiers bits qu'on ne regarde pas)
tempo2 movlw h'16'
movwf cmp2
movlw h'00'
movwf cmp1
t2 decfsz cmp1
goto t2
decfsz cmp2
goto t2
return
; tempo de 1200 bauds (833 µs, correspond à la vitesse choisie de la liaison RS232)
tempo3 movlw h'0F'
movwf cmp2
movlw h'02'
movwf cmp1
t3 decfsz cmp1
goto t3
decfsz cmp2
goto t3
return
end