I'm programming my pic16f628 in assembly to get a led blinking. I can get the led to turn on, but it isn't blinking. Here's my code:
Config bits:
Osc- IntRC Clkout
watchdog- off
power up timr- off
brown out detect- off
mclr enable- enabled
LV program- enabled
data ee read protect- off
code protect- off
The circuit has power hooked up, MCLR connected to +5v, a 4017 with clock pin on RA2, and a led with resistor on RA3. Power is provided from a 9v battery with a 7805 linear regulator.
I attached a 4017 decade counter to the RA2 pin to see if it was just blinking too fast to see. It's inconclusive. The light will start on different leds with no apparent pattern, but it will not move after that. The led on RA3 is always lit when power is connected.
Does anyone have any ideas?
Code:
STATUS equ 03h
PORTA equ 05h
TRISA equ 85h
count1 equ 07h
count2 equ 08h
;***set up ports, all porta pins to output***
bsf STATUS,5 ;go to bank 1
movlw b'00000000' ;set trisa,
movwf TRISA ;so all porta are outputs
bcf STATUS,5 ;now to bank 0
;Blinking portion of program start point
Start
;turn all PORTA ports high
movlw b'11111111' ;set all porta pins,
movwf PORTA ;to 1
;call a delay before turning leds off
call LongDelay
;now turn all leds off
movlw b'00000000' ;set all porta pins,
movwf PORTA ;to 0
;Call a delay
call LongDelay
;Now go back to start so the cycle repeats
goto Start
;***Delay subroutine, inserts a short delay
Delay
movlw 0xff
movwf count1
loop1
decfsz count1,1
goto loop1
return
;***LongDelay subroutine, inserts a long delay
LongDelay
movlw 0xff
movwf count2
loop2
call Delay
decfsz count2,1
goto loop2
return
;end program
end
Osc- IntRC Clkout
watchdog- off
power up timr- off
brown out detect- off
mclr enable- enabled
LV program- enabled
data ee read protect- off
code protect- off
The circuit has power hooked up, MCLR connected to +5v, a 4017 with clock pin on RA2, and a led with resistor on RA3. Power is provided from a 9v battery with a 7805 linear regulator.
I attached a 4017 decade counter to the RA2 pin to see if it was just blinking too fast to see. It's inconclusive. The light will start on different leds with no apparent pattern, but it will not move after that. The led on RA3 is always lit when power is connected.
Does anyone have any ideas?