jump from ISR


Closed Thread
Results 1 to 3 of 3

Thread: jump from ISR

  1. #1
    Join Date
    Oct 2007
    Location
    The Netherlands
    Posts
    45

    Default jump from ISR

    Hello everyone,
    I'm using DT's interrupts (very nice, thank you!) for the first time and run into a little problem which is probably easy to solve but I don't know how.
    When the user pushes a button the program should stop some motors and then jump back to wait for a next button push.
    If I use 'GOTO main' in my ISR it will not work, but how should I do it then? Any help appreciated.



    Code:
    ;Program Configuration Register 1
    @ __CONFIG _CONFIG1, _CP_OFF & _CCP1_RB3 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_OFF & _WDT_OFF & _INTRC_IO 
    
    ;Program Configuration Register 2
    @ __CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF
    
    INCLUDE "DT_INTS-14.bas"     ; Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ; Include if using PBP interrupts
    
    define  OSC 8
    DEFINE  ADC_BITS        8         ' Set number of bits in result
    DEFINE  ADC_CLOCK       3         ' Set clock source (3=rc)
    DEFINE  ADC_SAMPLEUS    50        ' Set sampling time in uS
    
    ANSEL        = %00000100        ' potmeter
    CMCON        = %00000111
    OSCCON       = %01111000        ' 8MHZ clock
    
    PORTA        = %00000000
    PORTB        = %00000000
    TRISA        = %00010100                
    TRISB        = %00001111   
    
    
    direction1 var PORTA.0
    direction2 var PORTA.1                                                                  
    test       var PORTA.4
    led        var PORTA.7
    motor1     var PORTB.4
    motor2     var PORTB.5
    
    counter  var byte
    duty      var byte
    wsave    VAR BYTE $70 SYSTEM      ' location for W if in bank0
    run        var bit
    
    clear
    
    led = 1    'led off
    
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    INT_INT,  _start_stop,   PBP,  yes          ; portb change interrupt
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    @   INT_ENABLE   INT_INT     ; enable external (INT) interrupts
    
    
    Main:         
            if run = 1 then
                direction1 = 1
                pause 100
                motor1 = 1
                pause 2000
                motor1 = 0
                pause 5000
                direction1 = 0
                pause 100
                motor1 = 1
                pause 2000
                motor1 = 0
                pause 5000          
                direction2 = 1
                pause 100
                motor2 = 1
                pause 4000
                motor2 = 0
                pause 5000
                direction2 = 0
                pause 100
                motor2 = 1
                pause 4000
                motor2 = 0
                pause 1000           
            endif        
    GOTO Main
    
    
    '---[INT - interrupt handler]---------------------------------------------------
    start_stop: 
       toggle run
       if run = 0 then 
          motor1 = 0
          motor2 = 0
          led =1
    'HERE I want it to go to Main again
       else
          led = 0
       endif       
       pause 500
       
    @ INT_RETURN
    end

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: jump from ISR

    Before each motor on command (motorx=1) add
    if run = 0 then goto main

    That way, If run gets set to 0 while in the run=1 loop, it can get out before turning any motors on
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3
    Join Date
    Oct 2007
    Location
    The Netherlands
    Posts
    45


    Did you find this post helpful? Yes | No

    Default Re: jump from ISR

    Thanks Bert,

    I thought of that too but assumed there would be an easier way.

    regards,

    eggman

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