Shop OBEX P1 Docs P2 Docs Learn Events
Why can I not use subrutines in my interrupt rutine when I program in SX/B — Parallax Forums

Why can I not use subrutines in my interrupt rutine when I program in SX/B

AtleAtle Posts: 5
edited 2008-06-08 15:11 in General Discussion
Hi,
I'm trying to call a subrutine from my interrupt rutine but I get an error 16 UNKNOWN COMMAND.
Is it not possible to call a subrutine from the interrupt rutine, and if not, why?

I put in an example program below to illustrate the error I get.

-Atle


'
' Device Settings
'

DEVICE SX48, OSCHS3
FREQ 50_000_000


'
' Variables
'
Tmp1 VAR Byte
Tmp2 VAR Byte

'
INTERRUPT 2000
'

ISR_Start:
' ISR code here
TogglePin

ISR_Exit:
RETURNINT ' {cycles}


' =========================================================================
PROGRAM Start
' =========================================================================

'
' Subroutines / Jump Table
'
TogglePin SUB

'
' Program Code
'

Start:
' initialization code here

TogglePin
TogglePin
' main code here
GOTO Start



'
' Use: UpdateTimerArray TimerArrayPosition ChannelNr

SUB TogglePin

Toggle RA.1

ENDSUB

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2008-06-07 16:58
    Put the sub definition
    '
    ' Subroutines / Jump Table
    '
    TogglePin SUB

    before the interrupt code.

    regards peter
  • BeanBean Posts: 8,129
    edited 2008-06-07 17:12
    Like this:

    ' -------------------------------------------------------------------------
    ' Device Settings
    ' -------------------------------------------------------------------------
    
    DEVICE SX48, OSCHS3
    FREQ 50_000_000
    
    
    ' -------------------------------------------------------------------------
    ' Variables
    ' -------------------------------------------------------------------------
    Tmp1 VAR Byte
    Tmp2 VAR Byte
    
    ' -------------------------------------------------------------------------
    INTERRUPT 2000
    
      GOTO ISR_Start
    
     
    ' -------------------------------------------------------------------------
    ' Subroutines / Jump Table
    ' -------------------------------------------------------------------------
    TogglePin SUB
    
    
     
    ' -------------------------------------------------------------------------
    ISR_Start:
    ' ISR code here
    TogglePin
    
    ISR_Exit:
    RETURNINT
    
    
    ' =========================================================================
    PROGRAM Start
    ' =========================================================================
    
    ' -------------------------------------------------------------------------
    ' Program Code
    ' -------------------------------------------------------------------------
    
    Start:
    ' initialization code here
      TogglePin
      TogglePin
      ' main code here
      GOTO Start
    
    
    ' -------------------------------------------------------------------------
    ' Use: UpdateTimerArray TimerArrayPosition ChannelNr
    
    SUB TogglePin
      Toggle RA.1
    ENDSUB
    


    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Did you know that 111,111,111 multiplied by 111,111,111 equals 12345678987654321 ?

    www.iElectronicDesigns.com



    Post Edited (Bean (Hitt Consulting)) : 6/7/2008 8:20:47 PM GMT
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2008-06-07 18:40
    I tried to compile that, there's a GOTO Int_start that should be GOTO ISR_Start.
  • BeanBean Posts: 8,129
    edited 2008-06-07 20:19
    Oops,
    Sorry about. Wasn't at a computer with the IDE.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Did you know that 111,111,111 multiplied by 111,111,111 equals 12345678987654321 ?

    www.iElectronicDesigns.com

    ·
  • JonnyMacJonnyMac Posts: 9,216
    edited 2008-06-08 04:48
    Reminder: There's a template in the SX/B ehlp file that will help you keep everything in the right place.
  • AtleAtle Posts: 5
    edited 2008-06-08 15:11
    This was great, helps me a lot.
    Thank you guys.

    -Atle
Sign In or Register to comment.