Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Hardware Stack Underflow error

Status
Not open for further replies.

vladtess

New Member
Hi there! When I test my PIC, I get "Hardware Stack Underflow" from my sim. (PIC16F84A) Here is the code:

Code:
	title "Program"
	include "p16f84a.inc"
	__CONFIG   _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC

	ORG 0X000
;===== variables ===========
count1 equ 0xC
value equ 0xD

;===== end variables =======

;===== set ports ======
	bsf STATUS,RP0 ;set PORTB, 0 to input, others to output
	movlw 0x1C	   
	movwf TRISA
	movlw 0xFF
	movwf TRISB
	bcf STATUS, RP0
; ====== end ======

	movlw 0x2
	movwf PORTA

start ;========================== digit 1 ======================
	movwf value
	btfsc PORTB, 0
	goto start
	btfsc PORTB,1
	goto start
	btfsc PORTB, 2
	goto start
	btfsc PORTB, 3
	goto start
	btfsc PORTB, 4
	goto start
	btfsc PORTB, 5
	goto start
	btfsc PORTB, 6
	goto start
	btfsc PORTB, 7
	goto start
	btfsc PORTA, 4
	goto start

	btfss PORTA, 3
	goto start
loop decfsz count1,1
	goto loop
	btfss PORTA,3

	goto start
	btfsc PORTA, 2
	goto term ; calling this sub causes error!  Everything else is ok!
	goto start

term
	movlw 0x0
	movwf value
return

	end

How can I avoid the error? Thanks much!!!!!!!!
 
Last edited:
You have a return without a call. Change it to an infinite loop instead.
Code:
term
	movlw	0x0
	movwf	value
hang	goto	hang

Mike.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top