Hi, im relatively new to programming and I just need some quick help. I have the pickit 2 with an included pic16f690. I have been trying to create a simple program that will simply blink an LED on and off continuously. It seems to build successfully but when i program it into the micro, it turns on and then blinks off twice before staying on the rest of the time. So it's not looping the way it should. I've done a lot of troubleshooting but I just can't seem to find the problem. If you guys need any more information let me know. Any help is much appreciated
Here's my code:
list p=16f690
#include <p16F690.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
org 0
;CONSTANTS
STATUS equ 03h
TRISC equ 87h
PORTC equ 07h
COUNT1 equ 08h ;08h and 09h are "unimplemented"
COUNT2 equ 09h
;SET UP PORTS
bsf STATUS,5 ;switch to Bank 1
movlw B'000000000' ;sets PORTC all to output
movwf TRISC
bcf STATUS,5 ;switch back to Bank 0
START
movlw B'00000001' ;moves value into w register
movwf PORTC ;from w to PORTC causing the LED to go LOW
Call DELAY ;goes through DELAY subroutine
movlw B'00000000' ;moves value into w register
movwf PORTC ;from w to PORTC causing the LED to go HIGH
Call DELAY
goto START
;Delay Subroutine
DELAY
LOOP
decfsz COUNT1,1 ;Counts down by 1 from 255
goto LOOP ;when COUNT1 is 0, it skips to LOOP2
LOOP2
decfsz COUNT2,1 ;so overall counts down from 255 255 times
goto LOOP ;when COUNT2 is 0, it returns to the main code
return
end
Here's my code:
list p=16f690
#include <p16F690.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
org 0
;CONSTANTS
STATUS equ 03h
TRISC equ 87h
PORTC equ 07h
COUNT1 equ 08h ;08h and 09h are "unimplemented"
COUNT2 equ 09h
;SET UP PORTS
bsf STATUS,5 ;switch to Bank 1
movlw B'000000000' ;sets PORTC all to output
movwf TRISC
bcf STATUS,5 ;switch back to Bank 0
START
movlw B'00000001' ;moves value into w register
movwf PORTC ;from w to PORTC causing the LED to go LOW
Call DELAY ;goes through DELAY subroutine
movlw B'00000000' ;moves value into w register
movwf PORTC ;from w to PORTC causing the LED to go HIGH
Call DELAY
goto START
;Delay Subroutine
DELAY
LOOP
decfsz COUNT1,1 ;Counts down by 1 from 255
goto LOOP ;when COUNT1 is 0, it skips to LOOP2
LOOP2
decfsz COUNT2,1 ;so overall counts down from 255 255 times
goto LOOP ;when COUNT2 is 0, it returns to the main code
return
end