Code:
org 00h
goto debut
org 05h
debut
clrf portA ; initialisation des portes
clrf portB
bsf statut,RP0 ; accès bank 1
movlw B'11111000'
movwf trisA
movlw B'00000111'
movwf trisB
bcf statut,RP0 ;accès bank0
clrf portA
CLRF potrB ; extintion des led
Ne pas confondre le "," et les ";" qui servent aux commentaires.
Ou sont connectées Les LEDs ?
bit 0 = 1
bit 1 = 2
bit 2 = 4
bit 3 = 8
Code:
movlw 02h
movwf portA
movlw 08h
movwf portB
ici tu allume une led sur le bit 1
pendand 2 µs
puis tu allume une Led sur le bit 3
Code:
ForEver
movlw 02h
movwf portA
call MyTempo ; 1sec
call MyTempo ; 1sec
call MyTempo ; 1sec
movlw 08h
movwf portB
call MyTempo ; 1sec
goto ForEver
;
; utilisé 20h compteur L et 21H compteur H
; 22H comme compteur 1/10 de seconde.
; comme compteur de tempo
; Le 020H fait 512 µs
; on met 195 dans 021H pour faire ~100 000 soit 1/10 de sec
; on met 10 dans 022H pour faire 1 seconde
MyTempo
movlw 0
movwf 020h
movlw 195
movwf 021h
movlw 10
movwf 022h
loop512us
decfsz 020H,f
decfsz 021H,f
decfsz 022H,f
return
end
Déjà testé ça !
et le modifier pour bien se familiariser avec.
Afin de bien maitriser !
Après on peut commencer des essais avec le timer.
3 couleurs !
Code:
ForEver
movlw 02h
movwf portA
call MyTempo ; 1sec
call MyTempo ; 1sec
call MyTempo ; 1sec
movlw 08h
movwf portB
call MyTempo ; 1sec
goto ForEver
movlw 04h
movwf portA
call MyTempo ; 1sec
call MyTempo ; 1sec
call MyTempo ; 1sec
goto ForEver