Interrupt stack overflow problem with Resume {label}


Closed Thread
Results 1 to 1 of 1
  1. #1
    Join Date
    Jan 2005
    Location
    Australia
    Posts
    20

    Exclamation 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
    Attached Files Attached Files
    Yuantu Huang

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  2. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  3. Software Stack
    By yasser hassani in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th December 2007, 10:04
  4. 18F452 "Unknown Processor" errors
    By schwinn_rider in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 27th April 2006, 03:56
  5. Interrupt Problem
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th November 2005, 20:58

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts