Habe mich wohl zu früh gefreut. Ich habe jetzt mal den Delay ein wenig verkürzt und schon machen die Leds nicht mehr das was ich will. Hier erst mal der Code:
Es soll folgendes passieren:Code:#include P16f88.INC ;*****Set up the Constants**** STATUS equ 03h ;Address of the STATUS register TRISA equ 85h ;Address of the tristate register for port A PORTA equ 05h ;Address of Port A COUNT1 equ 20h ;First counter for our delay loops COUNT2 equ 21h ;Second counter for our delay loops ;****Set up the port**** bsf STATUS,RP0 ;Switch to Bank 1 movlw 00h ;Set the Port A pins movwf TRISA ;to output. clrf ANSEL bcf STATUS,RP0 ;Switch back to Bank 0 movlw 00h ; movwf PORTA ;****Turn the 1st LED on**** Start movlw 04h ;Turn the Port A LEDs on by first putting it movwf PORTA ;into the w register and then on the port call Delay ;2nd LED movlw 08h ;Turn the Port A LEDs on by first putting it movwf PORTA ;into the w register and then on the port call Delay ;****Delay finished, now turn the LED off**** movlw 00h ;Turn the LEDs off by first putting it movwf PORTA ;into the w register and then on the port call Delay ;****Now go back to the start of the program goto Start ;go back to Start and turn LEDs on again ;****Here is our Subroutine Delay movlw 5 movwf COUNT1 ;Load count1 with init value movlw 5 movwf COUNT2 ;Load count1 with init value Loop1 decfsz COUNT1,f ;This second loop keeps the LEDs goto Loop1 ;turned off long enough for us to decfsz COUNT2,f ;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. end ;Needed by some compilers, and also ;just in case we miss the goto instruction.
LED1 an->Pause->LED1 aus und LED2 an->Pause->Neustart
Es passiert aber folgendes:
LED1 an-> Pause->LED1 aus und LED2 an->Pause->LED2 aus und LED1an> Pause->LED1 aus und LED2 an->lange Pause-> Neustart
Woher kommt diese lange Pause alle zwei Durchläufe ?
Wenn ich jetzt den Delay auf deinen ursprünglichen Wert erhöhe, dann
kommen nur zwei Wechsel anstatt drei vor der langen Pause.
LED 1 hängt übrigens an RA2 und LED2 an RA3.







Zitieren

Lesezeichen