jeremygaughan
New Member
Hi, I'm starting like most people doing a blinky program. I am running some code through the mplab sim to see if my program runs properly and to get a feel for the commands. When the program gets to my delay loop it seems to hit a snag. The sim says running.... and doesn't ever make any progress. Here is my code I imagine I am using the wrong registers for my count1 and count 2, or I have overlooked something else. Thanks for taking a look at my code.
list p=16f628a
#include <p16f628a.inc>
__config _CP_OFF & _WDT_OFF & _PWRTE_ON &
_BODEN_OFF &_INTRC_OSC_NOCLKOUT & _MCLRE_ON &
_LVP_OFF
ERRORLEVEL -302
;*****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 9Ah ;First counter for our delay loops
COUNT2 equ 9Bh ;Second counter for our delay loops
;****Set up the port****
bsf STATUS,5 ;Switch to Bank 1
movlw 00h ;Set the Port A pins
movwf TRISA ;to output.
movlw 85h ;set value of counter
movwf 9Ah ;move to counter folder
movlw 85h ;set value of counter2
movwf 9Bh ;move value to counter folder
bcf STATUS,5 ;Switch back to Bank 0
;****Turn the LED on****
Start
movlw 02h ;Turn the LED on by first putting it
movwf PORTA ;into the w register and then on the port
call Delay
movlw 00h ;Turn the LED off by first putting it
movwf PORTA ;into the w register and then on the port
call Delay
goto Start ;go back to Start and turn LED on again
Delay
Loop1
decfsz COUNT1,1 ;This second loop keeps the LED
goto Loop1 ;turned off long enough for us to
decfsz COUNT2,1 ;see it turned off
goto Loop1
return
;****End of the program****
end
list p=16f628a
#include <p16f628a.inc>
__config _CP_OFF & _WDT_OFF & _PWRTE_ON &
_BODEN_OFF &_INTRC_OSC_NOCLKOUT & _MCLRE_ON &
_LVP_OFF
ERRORLEVEL -302
;*****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 9Ah ;First counter for our delay loops
COUNT2 equ 9Bh ;Second counter for our delay loops
;****Set up the port****
bsf STATUS,5 ;Switch to Bank 1
movlw 00h ;Set the Port A pins
movwf TRISA ;to output.
movlw 85h ;set value of counter
movwf 9Ah ;move to counter folder
movlw 85h ;set value of counter2
movwf 9Bh ;move value to counter folder
bcf STATUS,5 ;Switch back to Bank 0
;****Turn the LED on****
Start
movlw 02h ;Turn the LED on by first putting it
movwf PORTA ;into the w register and then on the port
call Delay
movlw 00h ;Turn the LED off by first putting it
movwf PORTA ;into the w register and then on the port
call Delay
goto Start ;go back to Start and turn LED on again
Delay
Loop1
decfsz COUNT1,1 ;This second loop keeps the LED
goto Loop1 ;turned off long enough for us to
decfsz COUNT2,1 ;see it turned off
goto Loop1
return
;****End of the program****
end