Dein PIC hat keinen Takt. Der RC Oszillator gehört an OSC1 nicht an OSC2. Außerdem empfiehlt das Datenblatt einen R1 von <= 100kOhm.
Hast du das gefixt ist sicherlich die Delay Routine viel zu lange. Bei Verwendung von 220pF und 100kOhm hast du ganz grob einen Takt von 40kHz. Durch 4 gibt das intern 10kHz Ausführungsgeschwindigkeit. Deine Delay Routine ist eine Doppelt verschachtelte Schleife mit insgesamt
255*255=65025 Durchläufen. Enthalten sind zwei Befehle. Das ergibt einen Delay von rund 12 Sekunden.
Außerdem lädst du die Register nicht mit sinnvollen Werten vor. Dadurch ist es beim ersten Durchlauf dem Zufall überlassen was drin steht. Später stehen die dann immer auf Null und springen durch decfsz auf 255.
Schau mal den modifzierten Code an. Dort sollten die LEDs mit dem Vorgeschlagenen Oszillator grob im 1/2 Sekundentakt blinken.
Generell:
ich würde bevorzugt die vordefinierten macros verwenden.
Statt
bsf STATUS,5
besser
bsf STATUS, RP0
oder besser gleich
banksel TRISA
statt
decfsz COUNT1,1
besser
decfsz COUNT1,f
macht das ganze lesbarer und weniger fehleranfällig.
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
;****Turn the LED on****
Start movlw 1Fh ;Turn the Port A LEDs on by first putting it
movwf PORTA ;into the w register and then on the port
;****Add a delay
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
;****Add another delay****
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 255
movwf COUNT1 ;Load count1 with init value
movlw 10
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.
Lesezeichen