Hallo,
nochmal mein Assembler-Programm für meinen PIC16F627…
Die LED blinkt ja nun, ich hab auch schon (in einem anderen Programm allerdings) Pulsweitenmodulation hingekriegt und die Helligkeit geändert. Aber an den Tastern an Port A (genauer gesagt, der Abfrage, ob die Pins high oder low sind) scheitere ich 
An Port B hängen LEDs, an Port A0-3 über Widerstände Erde. Wird ein Taster gedrückt, wird zu +5V durchgeschaltet. Der Pin sollte somit high werden und die Blinkfrequenz müsste sich halbieren. Tut sie aber nicht; es passiert gar nichts, die LEDs blinken fleißig weiter. Und wie zuvor finde ich mal wieder keinen Fehler…muss man beim Abfragen irgendwas Wichtiges beachten, was in meinem Programm fehlt? In einigen Beispielprogrammen (bei denen die Taster funktionieren) sehe ich keinen Unterschied (was allerdings auch an dem Wirrwar aus Konstanten im liegen könnte), das finde ich sehr mysteriös…
Gleich folgt nochmal das Programm, leider wieder sehr hässlich.
mfg
MB
;*****Set up the Constants****
STATUS equ 03h ;Address of the STATUS register
TRISB equ 86h ;Address of the tristate register for port A
PORTB equ 06h ;Address of Port A
TRISA equ 85h ;Address of the tristate register for port A
PORTA equ 05h ;Address of Port A
COUNT1 equ 08h ;First counter for our delay loops
COUNT2 equ 09h ;Second counter for our delay loops
;****Set up the port****
bsf STATUS,5 ;Switch to Bank 1
movlw b’00000000’ ;Set the Port B pins to output
movwf TRISB
movlw b’11111111’ ;Set the Port A pins to input
movwf TRISA
bcf STATUS,5 ;Switch back to Bank 0
;****Turn the LED on****
Start movlw b’00100000’ ;Turn the LED on by first putting
movwf PORTB ;it into the w register and then
;on the port
;****Start of the delay loop 1****
call Delay
btfsc PORTA,0
call Delay
;****Delay finished, now turn the LED off****
movlw b’00000001’ ;Turn the LED off by first putting
movwf PORTB ;it into the w register and then on
;the port
;****Add another delay****
call Delay
btfsc PORTA,0
call Delay
;****Now go back to the start of the program
goto Start ;go back to Start and turn LED
;on again
;****Here is our Subroutine
Delay
Loop1 decfsz COUNT1,1 ;This second loop keeps the LED
goto Loop1 ;turned off long enough for us to
decfsz COUNT2,1 ;see it turned off
goto Loop1
return
;****End of the program****
end ;Needed by some compilers,
;and also just in case we miss
;the goto instruction.


