RobertD
New Member
(I'm not an OP btw)
Hi folks, I get the message 'stack underflow' after the return from delay command. As discussed earlier, I included this code
I guess to initiate the stack, I don't understand the operation of the stack too well, when does it push, and when it pops. When I run the sim, it works fine, but on the chip, TIMER1 hangs around 88 all the time. And the LED doesn't flash.
Hi folks, I get the message 'stack underflow' after the return from delay command. As discussed earlier, I included this code
Code:
[b]main btfsc PORTB,4
goto main[/b]
main1 bsf PORTA,6
call delay
bcf PORTA,6
call delay
goto main1
I guess to initiate the stack, I don't understand the operation of the stack too well, when does it push, and when it pops. When I run the sim, it works fine, but on the chip, TIMER1 hangs around 88 all the time. And the LED doesn't flash.
Code:
list p=16F88
include <p16f88.inc>
__config _CONFIG1, _WDT_OFF & _INTRC_IO & _MCLR_ON & _LVP_OFF
cblock 0x40
TIMER1, TIMER2
endc
banksel TRISA ;bank 1
movlw 0x42 ;1MHz clock
movwf OSCCON
movlw 0x07 ;turn comparators off
movwf CMCON
movlw B'11111111'
movwf TRISB ;all input.
movlw B'00000010' ;all RA ports all outputs except A/D (RA1) input
movwf ANSEL
movwf TRISA
movlw B'00000000'
movwf OPTION_REG ;make all PORTB pins 1
banksel PORTA
clrf PORTA
goto main
main
btfsc PORTB,4
goto main
main1
bsf PORTA,7
call delay
bcf PORTA,7
call delay
goto main1
delay
MOVLW D'100'
MOVWF TIMER1
DELAY2
MOVLW D'200'
MOVWF TIMER2
DECFSZ TIMER2,F
GOTO $-1
DECFSZ TIMER1,F
GOTO DELAY2
return
end
Last edited: