Beruflich Dokumente
Kultur Dokumente
Programme on MicroC
2)Commande d’un Feu Routier :
Le programma en assembleurs
3)Réalisation d’un jeu de lumière à séquences multiples
Le programme on assembleur
cblock 0x00C
i :1
n :1
endc
init
movlw 0x03 ;
clrf TRISB
debut
movf PORTA,W
movwf n
movlw 0x00
xorwfn,W
btfss STATUS,Z
goto test2
call progF1
goto debut
test2
movlw 0x01
xorwfn,W
btfss STATUS,Z
goto test3
call progF2
goto debut
test3
movlw 0x02
xorwfn,W
btfss STATUS,Z
goto test4
call progF3
goto debut
test4
movlw 0x03
xorwfn,W
btfss STATUS,Z
goto debut
call progF4
goto debut
end
progF1
bsf portb,7
x1 call tempo
bcf STATUS,C
rlf portb,f
btfss status,c
goto x1
bsf portb,0
x2 call tempo
bcf STATUS,C
rrf portb,f
btfss STATUS,C
goto x2
return
progF2
clrf i
movlw 0xAA
movwf portb
incf i,f
comf portb,f
movlw 0x0a
xorwfi,W
btfss STATUS,Z
goto rbt
return
progF4
movlw b'11000000'
movwf portb
lolo
call tempo
bcf STATUS,C
rrf portb,f
btfss status,c
goto lolo
movlw 0x03
movwf portb
zozo
call tempo
bcf STATUS,C
rlf portb,f
btfss STATUS,C
goto zozo
return
;--------------- Programme principal ----------------------
progF3
clrf portb
P3 movf i,W
CALL sq
MOVWF PORTB
INCF i,F
MOVLW 0X07
XORWF i,W
BTFSS STATUS,Z
GOTO P3
return
;-------------------------sous programm--------------------
sq
ADDWF PCL,F
RETLW 0X81
RETLW 0XC3
RETLW 0XE7
RETLW 0XFF
RETLW 0XE7
RETLW 0XC3
RETLW 0X81
Return
Conclusion
1. Pour écrire un programme on a besoin d’un éditeur de texte et un
compilateur
2. Il est obligatoire de définir la librairie du PIC utilisé
3. Il est obligatoire de faire « ; » à la fin de chaque instruction
4. « // » pour écrire un commentaire