Stack underflow

inxanu

New Member
Hi everyone,

I'm making a project, and i've read something about resolving some issue with stacks underflow. could someone help me with this one?

I get one stack underflow after getting back from an interruption with the pic16F877, this is the code:


INT
BTFSS INTCON,INTF
GOTO BACK
MOVF DEMORA,W ; Valor de demora para el TRIAC
MOVWF TMR0
CLRF PORTA
WAIT
BTFSS INTCON,T0IF
GOTO WAIT ; ESPERO EL DESBORDE DE TMR0 ENCUESTANDO LA BANDERA DE TMR0
BCF INTCON,T0IF ; LIMPIO LA BANDERA
MOVLW B'00000010'; DISPARO LOS TRIACS
MOVWF PORTB
BSF 3,5
BTFSS OPTION_REG,INTEDG
GOTO SETTING
BCF OPTION_REG,INTEDG
BCF 3,5
GOTO BACK
SETTING
BSF OPTION_REG,INTEDG
BCF 3,5
BACK
BCF INTCON,INTF
RETFIE


Thank you for your help!
 
Use code tags so we can read it.
 
Code:
INT
         BTFSS INTCON,INTF
         GOTO BACK 
         MOVF DEMORA,W ; Valor de demora para el TRIAC
         MOVWF TMR0
         CLRF PORTA
WAIT
         BTFSS INTCON,T0IF
         GOTO WAIT ; ESPERO EL DESBORDE DE TMR0 ENCUESTANDO LA BANDERA DE TMR0
         BCF INTCON,T0IF ; LIMPIO LA BANDERA
         MOVLW B'00000010'; DISPARO LOS TRIACS
         MOVWF PORTB
         BSF 3,5
         BTFSS OPTION_REG,INTEDG
        GOTO SETTING
        BCF OPTION_REG,INTEDG
        BCF 3,5
        GOTO BACK
SETTING
        BSF OPTION_REG,INTEDG
        BCF 3,5
BACK
        BCF INTCON,INTF
        RETFIE


I'm sorry,. My first time!
 
Last edited:
Right at the top - if TMR0 throws the interrupt, but INTF = 0, the routine goes to "BACK" and RETFIE without clearing T0IF.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…