zhaniko93
New Member
Hey I am new in PIC-s and I have compiled a little program which simply puts logical 1 on porta's first pin. Here's the code:
When I try to debug it in MPLAB SIM, it loops in subroutine forever(i.e. it performs Init clrf porta, and everything before retlw 0 then it doesn't jump to Main, it goes back up to Init clrf porta and it continues forever), when I tried to simulate in Proteus,. it Gave error: Stack underflow executing RETLW instruction. whats wrong? what am i doing incorrectly? P.S. sry for bad english ![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Code:
list P=16F72
include "c:\PIC\_inc\P16F72.inc"
__config _RC_OSC & _WDT_OFF & _CP_OFF
;============
; Declarations:
porta equ 05
org 1FF
goto Start
org 0
;============
; Subroutines:
Init clrf porta ; resets Port A
movlw b'0000' ; RA0: LED, RA1-3: not connected
bsf STATUS, RP0
movwf TRISA
bcf STATUS, RP0
retlw 0
;============
; Program Start:
Start call Init ; sets up inputs and outputs
Main bsf porta, 0 ; turns on LED
goto Main ; loops back to Main
END