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.

Stack underflow

Status
Not open for further replies.

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.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top