Mein LED Lauflicht funktioniert inzwischen. Allerdings hat sich jetzt ein neues Problem ergeben. Der PIC läuft nicht kontinuierlich durch, sondern startet das Programm nach einer bestimmten Zeit immer neu. Das erkenne ich daran, dass das Lauflicht nach einem Mal durchlaufen nur noch ein halbes Mal durchläuft und dann wieder von vorne anfängt.
Ich versorge den PIC mit 5V über ein USB-Kabel. Benutzen tue ich den internen Oszilator des PIC16F88. Zur Entstörung habe ich schon einen 100nF Kondensator zwischen VDD und VSS gehängt (direkt unter die Pins). Wie kann ich dieses Problem beheben?
Hier ist zur Sicherheit auch nochmal der Code:
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 TRISB equ 86h PORTB equ 06h OSCCON equ 8Fh COUNT1 equ 20h ;First counter for our delay loops COUNT2 equ 21h ;Second counter for our delay loops ;****Set up the port**** call Delay bsf STATUS,RP0 ;Switch to Bank 1 movlw 10h ;Set the Port A pins movwf TRISA movlw 01h ;Set the Port B pins movwf TRISB movlw 2Eh movwf OSCCON clrf ANSEL bcf STATUS,RP0 ;Switch back to Bank 0 movlw 00h ; movwf PORTA movlw 00h movwf PORTB ;****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 btfsc PORTA,4 ;if RA4 is on, the next instruction is skipped 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 btfsc PORTA,4 call Delay ;3rd LED**** movlw 00h ;Turn the LEDs off by first putting it movwf PORTA ;into the w register and then on the port movlw 02h ;Turn LED on RB1 on movwf PORTB call Delay btfsc PORTA,4 call Delay ;4th LED movlw 04h movwf PORTB call Delay btfsc PORTA,4 call Delay ;5th LED movlw 10h movwf PORTB call Delay btfsc PORTA,4 call Delay ;6th LED movlw 20h movwf PORTB call Delay btfsc PORTA,4 call Delay ;turn all off movlw 00h movwf PORTB call Delay btfsc PORTA,4 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 30 movwf COUNT1 ;Load count1 with init value movlw 10 movwf COUNT2 ;Load count2 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.






					
					
					
						
Zitieren

Lesezeichen