Stack Under flow


Results 1 to 10 of 10

Threaded View

  1. #1
    Join Date
    Sep 2005
    Location
    Hernando,Florida USA
    Posts
    8

    Red face Stack Under flow

    I seem to have a problem with the stack.
    But a stack under flow ??
    When my program get to a return I get this message
    "Stack under flow error occurred from instruction at 0x000126"
    the return instruction is at 0x000126.
    The tools are PIC Pro 2.46 MPLAB 7.20 and the device is 16F913
    Just don't know where to start with this problem.
    I start the program, it will go through the getkey loop 2 times
    and then give me the stack error. then it resets and starts over.

    ************************************************** ****

    Define osc 8
    OSCCON = %01110001 'SET FOR INTERNAL CLK @8 MHz
    WDTCON = %00000000
    LCDCON = %01000000
    LCDSE0 = %00000000
    LCDSE1 = %00000000
    ANSEL = 0
    CMCON0 = $07


    TRISB=%00001111 'set PORTb, 1=input, 0=output
    TRISC=%11110000 'set PORTc, 1=input, 0=output
    TRISA=%11100100 'set PORTa, 1=input, 0=output


    PORTB.4=0 ' set portb pin 4 low for LED sink
    PORTA.0=0
    INTCON = %00000000 'Turn interrups off

    kp VAR BYTE 'Key press value
    kp1 VAR BYTE 'Key press
    LED1 VAR PORTA.0
    LED2 VAR PORTA.1
    LED3 VAR PORTA.3
    LED4 VAR PORTA.4
    LEDCOM VAR PORTB.4
    TESTPIN VAR PORTC.5
    COL1 VAR PORTC.0 'KeyPad col1
    COL2 VAR PORTC.1 'KeyPad col2
    COL3 VAR PORTC.2 'KeyPad col3
    COL4 VAR PORTC.3 'KeyPad col4
    ROW VAR BYTE
    i VAR BYTE 'for next variable

    '************************************************* **
    start:

    LED1=0 '
    LED2=0 ' set all leds to Off
    LED3=0 '
    LED4=0 '
    LEDCOM=0
    kp=16
    kp1=0


    LED1 = 1
    Pause 500
    LED2 = 1
    Pause 500
    LED3 = 1
    Pause 500
    LED4 = 1
    Pause 500
    LED1 = 0
    LED2 = 0
    LED3 = 0
    LED4 = 0

    main:
    GoSub getkey

    getkey:
    kp1=0 'Clear kp1


    'col4

    PORTC=%00000111 'Make PORTC.3 low PINs .0.1.2 High
    kp1 = PORTB & $0f
    IF kp1=14 Then kp=13
    IF kp1=13 Then kp=14
    IF kp1=11 Then kp=15
    IF kp1=7 Then kp=15
    IF kp1<>15 Then debounce

    'col3

    PORTC=%00001011 'Make PORTC.2 low PINs .3.1.0 High
    kp1 = PORTB & $0f
    IF kp1=14 Then kp=3
    IF kp1=13 Then kp=6
    IF kp1=11 Then kp=9
    IF kp1=7 Then kp=12
    IF kp1<>15 Then debounce

    'col2

    PORTC=%00001101 'Make PORTC.1 low PINs .3.2.0 High
    kp1 = PORTB & $0f
    IF kp1=14 Then kp=2
    IF kp1=13 Then kp=5
    IF kp1=11 Then kp=8
    IF kp1=7 Then kp=10
    IF kp1<>15 Then debounce

    'col1

    PORTC=%00001110 'Make PORTC.0 low PINS .3.2.1 High
    kp1 = PORTB & $0f
    IF kp1=14 Then kp=1
    IF kp1=13 Then kp=4
    IF kp1=11 Then kp=7
    IF kp1=7 Then kp=11
    IF kp1<>15 Then debounce

    GoTo nokey
    debounce:
    pause 50
    row = PORTB & $0f
    if row = $f then showkp
    goto debounce

    showkp: For i = 1 to kp
    High led1
    Pause 500
    Low led1
    Pause 500
    Next i
    'DTMFout PORTC.5,[kp]
    nokey:

    Return
    end
    '*************************************
    Last edited by Wayne; - 14th September 2005 at 02:07. Reason: more data

Similar Threads

  1. Hall Effect flow meter with 16F876
    By revelator in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th March 2010, 20:42
  2. Software Stack
    By yasser hassani in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 18th December 2007, 10:04
  3. Stack over flow with IF THEN RETURN ENDIF???
    By kdoske in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 9th December 2007, 17:20
  4. hot water flow sensor
    By jessey in forum Off Topic
    Replies: 16
    Last Post: - 24th January 2007, 04:05
  5. 48 level Software Stack
    By Darrel Taylor in forum Code Examples
    Replies: 0
    Last Post: - 30th November 2003, 01:07

Members who have read this thread : 0

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