View Single Post
  #8   Spotlight this post!  
Unread 28-02-2007, 15:24
dcbrown dcbrown is offline
Registered User
AKA: Bud
no team
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Hollis,NH
Posts: 236
dcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud ofdcbrown has much to be proud of
Re: How do I know if I'm overloading the RC program?

Also be aware that the hardware call (PC address) stack is limited. The 256 bytes of allocate stack space in ram/bank memory is for allocation of automatic variables at function call time.

"After the PC is pushed onto the stack 31 times (without popping any values off the stack), the STKFUL bit is set. The STKFUL bit is cleared by software or by a POR (Power-On-Reset)." [PIC Spec]

Typically the processor will reset when the STKFUL bit is set, but the behavior depends on the state of the STVREN (Stack Overflow Reset Enable) configuration bit. This should be enabled to allow the resets in FIRST environments. Runaway re-entrant functions will cause bad behavior including resets as a result of stack overflow. Moreover, out of the stack depth must be reserved call space for low and high interrupts. If the chip isn't being reset because STVREN is clear, then you should be able to check the STKFUL bit in the STKPTR hardware register as the bits will remain on until POR condition or software resets them.

Code:
The high priority interrupt is a two deep stack on the slave processor:
     . (1) InterruptHandlerHigh
         . (2) Prep_SPI_4_First_Byte
         . (2) Handle_Spi_Int
Code:
The low priority interrupt is at least another 4 stack levels in the MPLAB default environment:
     . (1) InterruptHandlerLow
         . (2) CheckUartInts
              . (3) Handle_Panel_Data
              . (3) Process_TX
                   . (4) DisableXmitInts
              . (3) Serial_Char_Callback

So at LEAST 6 stack frames must be reserved for interrupts, maybe more.

Bud