Assembler Ampel

Dies war mein erstes Assembler Programm für den PIC16F84. Leicht unübersichtlich aber es funktioniert. Das Bild zeigt die Platine, auf der der PIC seit einiger Zeit läuft. Die Ampel steht inzwischen im Garten.

Layout

Quelltext:
list p=16f84
#include <P16f84a.INC>
__CONFIG _PWRTE_ON & _WDT_OFF & _XT_OSC
loops Equ 0x22
loops2 Equ 0x23
loops3 Equ 0x24
Init
bsf STATUS, RP0
movlw B'00000000'
movwf TRISB
bcf STATUS, RP0
clrf PORTB
bsf PORTB,0
Loop

movlw D'20'
movwf loops3
call Waiths
bsf PORTB,1
movlw D'3'
movwf loops3
call Waiths
bcf PORTB,0
bcf PORTB,1
bsf PORTB,2
movlw D'20'
movwf loops3
call Waiths
bcf PORTB,2
bsf PORTB,1

movlw D'3'
movwf loops3
call Waiths
bcf PORTB,1
bsf PORTB,0

goto Loop

Waiths

Wait
movlw D'250'
movwf loops
Wai
movlw .220 ; Zeitkonstante fuer 2ms
movwf loops2
Wai2 nop
nop
nop
nop
nop
nop
decfsz loops2, F
goto Wai2
decfsz loops, F
goto Wai
decfsz loops3, F
goto Waiths
retlw 0
end