Shop OBEX P1 Docs P2 Docs Learn Events
calling a SUB or FUNC from an ISR — Parallax Forums

calling a SUB or FUNC from an ISR

TransistorToasterTransistorToaster Posts: 149
edited 2006-11-24 10:15 in General Discussion
Hello,
Just wondering if anybody managed to call a SUB or a FUNC from an ISR in SX Basic. I tired declaring the SUB and FUNC in various places of the template, but with no success. I use the following template outline:
INTERRUPT 1000
ISR_start:
...code
ISR_Exit:
PROGRAM Start
subname SUB 2
Start:
Main:
GOTO Main

Now, subname SUB 2 declared that way allows subname to be called from anywhere except from the ISR, where the compiler complains with an "unknown command". If I declare it before INTERRUPT 1000, then I get"overwriting same program counter data." If I declare it after INTERRUPT 1000, then I in the dissasembly, I get a JMP right away at addess 0. Maybe I could declare the subname SUB 2 totally at some arbitrary point in the middle of the ISR and GOTO around it, but that looks messy.

What do I do?

Frank

Comments

  • BeanBean Posts: 8,129
    edited 2006-11-24 10:15
    Frank,
    Do it this way...

    INTERRUPT 1000
    GOTO Handle_Int

    subname SUB 2

    Handle_Int:
    ' Put interrupt code here
    RETURNINT

    PROGRAM Start

    Start:
    Main:
    GOTO Main

    subName:
    ' Subroutine code here
    RETURN

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap used 4-digit LED display with driver IC·www.hc4led.com

    Low power SD Data Logger www.sddatalogger.com
    SX-Video Display Modules www.sxvm.com
    Stuff I'm selling on ebay http://search.ebay.com/_W0QQsassZhittconsultingQQhtZ-1

    "People who are willing to trade their freedom for·security deserve neither and will lose both." Benjamin Franklin
    ·
Sign In or Register to comment.