Searching \ for '[PIC]: INT/RB0 & Stack?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'INT/RB0 & Stack?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: INT/RB0 & Stack?'
2001\01\18@094629 by Francois Robbertze

flavicon
face
Dear Piclist Members,
I am using a PIC16F84 and when I initiate a interrupt on pin 6(RB0) then the program jumps to my interrupt routine...

If I flush a led in the interrupt routine and do a retfie then the program jumps back to my main loop - OK

If I do a call to Subroutine and the a return to the Interrupt routine and then a retfie to the main routine, the program never get into the main program again...Why?

Is the size of the stack smaller than 8 if in a interrupt routine?

Regards

Francois


             lllllllllll
            \\  ~ ~ //
            ( @ @ )
o------oOOo-(_)-oOOo-----o
|                                   |
|   Francois Robbertze    |
|    spam_OUTfr10TakeThisOuTspammweb.co.za     |
|                                   |
o--------.oooO-Oooo.-------o

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\18@095740 by Drew Vassallo

picon face
>If I do a call to Subroutine and the a return to the Interrupt routine and
>then a retfie to the main routine, the program never get into the main
>program again...Why?
>
>Is the size of the stack smaller than 8 if in a interrupt routine?

No.  Are you using "retfie" from the subroutine by mistake?  This could
enable interrupts again before you return.  Also, make sure you are clearing
the flag bits before executing "retfie".

Also make sure you aren't overflowing the stack when you call these new
subroutines.  Maybe you were at 8 already and the extra subroutine overflows
it.

To be honest, I never have counted the exact max. stack level in my
programs... I just kind of "feel" that I'm not calling too many subroutines
from other subroutines.  Not very scientific, but I haven't had problems yet
(knock on wood).

--Andrew
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\18@105130 by Alan B. Pearce

face picon face
>To be honest, I never have counted the exact max. stack level in my
>programs... I just kind of "feel" that I'm not calling too many subroutines
>from other subroutines.  Not very scientific, but I haven't had problems yet
>(knock on wood).

would this not be more a case of "resort to simulator". MPLAB can be set up to
tell you when you go into stack overflow.

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\18@113058 by Steven J. Devine

flavicon
face
>I am using a PIC16F84 and when I initiate a interrupt on pin 6(RB0)
>then the program jumps to my interrupt routine...
>
>If I flush a led in the interrupt routine and do a retfie then the program
>jumps back to my main loop - OK
>
>If I do a call to Subroutine and the a return to the Interrupt routine
>and then a retfie to the main routine, the program never get into the
>main program again...Why?
>
>Is the size of the stack smaller than 8 if in a interrupt routine?

I just want to clarify something... when you say that you call a subroutine, then return to the interrupt routine, do you mean that you are calling the interrupt routine directly, and not getting there via an actual interrupt?

I would think that  RETFIE would only work if the routine was triggered by an interrupt.

Also, if you were in a subroutine, and an interrupt occurred, the ISR would be invoked, and control would return back where it left off, in the subroutine, and NOT the main routine...

Steve

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\18@113718 by Drew Vassallo

picon face
> >To be honest, I never have counted the exact max. stack level in my
> >programs... I just kind of "feel" that I'm not calling too many
>subroutines
> >from other subroutines.  Not very scientific, but I haven't had problems
>yet
> >(knock on wood).
>
>would this not be more a case of "resort to simulator". MPLAB can be set up
>to
>tell you when you go into stack overflow.

Sure, *IF* you can simulate your entire code.  With almost 2k of program
memory used up and any number of subroutines that interface with external
devices, interrupts, etc. there is no practical way to simulate everything
to check the stack level.  You'd have a tougher time trying to predict what
might happen during run-time and entering the commands manually into the
debugger than you would just going through your subroutines and counting up
the calls by hand.

--Andrew
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\19@021449 by Francois Robbertze

flavicon
face
>I just want to clarify something... when you say that you call a
subroutine, then return to the interrupt >routine, do you mean that you are
calling the interrupt routine directly, and not getting there via an >actual
interrupt?

No, the interrupt gets triggered on a faling edge of RB0. My code looks
something like this:

;************************************ORIGIN*********************************
*
       Org     0
       Goto   Main
       Org     4
       Goto    INT_handler

;*********************************** MAIN
***********************************
Main
       Call     RegulateTemperature
       Goto    Main

;************************ INTERRUPT HANDLER *************************
INT_handler
    movwf   savedW
    swapf   StatusReg, 0
    movwf   savedSTAT

    call IncommingData

    swapf   savedSTAT, 0
    movwf   StatusReg
    swapf   savedW, 1
    swapf   savedW, 0

    bcf IntConReg, 1         ;clear interrupt flag
    retfie
;************************ Regulate Temperature*************************
   Call    SubroutineX
   Return
;*************************** IncommingData*****************************
;Do some things
   Call    SubroutineA
   Call    SubroutineB
   Return
;***************************** SubroutineA ******************************
   Call    Subroutine C
;Do some things
   Return
;******************************SubroutineB*******************************
;Do some things
   Return
;******************************SubroutineC*******************************
;Do some things
   Return
;***************************************************************************
   END

I am now sure I was not overflowing the stack. I think my fault was that in
the RegulateTemperature routine I was waiting for a Dallas 18A20 to respond
with a temperature reading when the interrupt normally occurs. Thus when the
interrupt routine was exit with the RETFIE command, the stack "POPPED"
backed into an endless loop, because it is waiting for the Dallas18A20 to
respond and this thermometer has time out...and back in a idle state.

Regards

Francois

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...