1 Attachment(s)
	
	
		Interrupt stack overflow problem with Resume {label}
	
	
		Dear All,
My application needs interrupt using "Resume Label" statement to do the special job. However, it can only do 27 times for me, then resets doing 27 times job again, and then stops working. After reading the PBP Manual and Melanie' thread posted on 14th April 2004, I think it may be the stack overflow problem and do not know how to fix.
I believe that the PBP Forums can give the suggestion and help to solve the problem.
The testing code using PIC18F4525 is below and also attached.
'   The following program may suffer interrupt stack overflow problem.
'   Reset after Counter == 27 for the first time, 
'   and then die when Counter == 27 for the second time
'
'   Target:PIC18F4525
'   The following configuration bits were used
'   __CONFIG    _CONFIG1H,_OSC_INTIO67_1H
'	__CONFIG    _CONFIG2L, _PWRT_ON_2L & _BORV_27_2L
'	__CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
'   __CONFIG    _CONFIG3H, _MCLRE_ON_3H & _PBADEN_OFF_3H
'   __CONFIG    _CONFIG4L, _LVP_OFF_4L & _ENHCPU_OFF_4L
    DEFINE OSC 8
    
    ; LCD definition
    define LCD_DREG PORTD
    DEFINE LCD_DBIT 0
    DEFINE LCD_RSREG PORTD
    DEFINE LCD_RSBIT 4
    ' Make LCD display in 4 line mode
	DEFINE LCD_LINES 4
	' Set LCD Enable port
	DEFINE LCD_EREG	PORTD
	' Set LCD Enable bit
	DEFINE LCD_EBIT	5
	
	Counter var word
    
	' Init internal clock and others
    OSCCON  = %01110111	' Use internal 8MHz clock
	ADCON1	= %00001111	' Disable A/D convertor
	TRISD   = %00000000 ' PORTD Set as outputs
    INTCON  = %10100000 ' Enable global interrupt
                        ' Enable Timer0 overflow interrupt
    T0CON   = %00010111 ' Set 1:256 prescale
    TMR0L   = 0         ' Make a second interval using TMR0L & TMR0H to
    TMR0H   = 223       ' interrupt every second or so
    T0CON.7 = 1         ' Enable Timer0
    'RCON   = 1         ' no effect, 0 or 1 got the same result 
    
    	
    counter = 0
    Pause 2000      	' Wait for LCD and PIC to startup (tested: 1000-10000)
    LCDOUT $FE, 1, #Counter
    
    'clearwdt           ' no effect
    goto MainLoop
' Interrupt subroutine     
Disable
CounterISR:
    Counter = Counter + 1
    TMR0L = 0
    TMR0H = 223     ' Set one second interval
    INTCON.2 = 0    ' Make the timer0 interrupt again 
    resume Location ' If remove Location, 
                    ' counter is right & PIC never reset or die
    resume 
Enable
    on interrupt goto CounterISR
         
 Location:
        LCDOUT $FE, 1, #Counter
 
 MainLoop:
    pause 1             ' If comment it out, reset forever, why?
    goto MainLoop
       
    end
Thank you for your help