16f688 interrupt


Closed Thread
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Add DISABLE/ENABLE around the interrupt handler, and any subroutines called from the handler.
    Without them, the interrupt handler will continuously interrupt itself.
    Code:
    DISABLE
    buttonpressed:
        gosub All_on
        dummy=porta  ; clear mismatch condition
        INTCON.0 = 0   ; reset interrupt flag
    resume                     
    ENABLE
    
     ...
    
    DISABLE
    all_on:
      a=7:c=63
      pause t1
    return
    ENABLE
    DT

  2. #2


    Did you find this post helpful? Yes | No

    Default

    thank you for all of your help, but is there a way to make it so that when you press the button it loops one program continously then, when pressed again goes to another program?

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by RHS_electronics View Post
    thank you for all of your help, but is there a way to make it so that when you press the button it loops one program continously then, when pressed again goes to another program?
    Untested but worth a try:
    Code:
    Button_Flag VAR BIT
    DUMMY       VAR BYTE
    Trisa = 32
    Trisc = 0
    
    
    a Var porta:c var portc
    x var word:t1 var word
    
    
    x=0
    t1=200
    
    ANSEL = 0
    ioca=%00100000
    CMCON0 = 7
    start:
    
    on interrupt goto buttonpressed
    INTCON = %10001000 
    DISABLE
    buttonpressed:
    IF Button_Flag = 1 THEN
        gosub All_on
        ELSE
        gosub LEFT
        endif
        dummy=porta  ; clear mismatch condition
        INTCON.0 = 0   ; reset interrupt flag
    
    resume                     
    ENABLE
    
     '...
    
    DISABLE
    all_on:
      a=7:c=63
      Button_Flag = 1
      pause t1
    return
    ENABLE
    
    DISABLE
        LEFT:
        A=4 : c=36:
        Button_Flag = 0
        pause t1
    a=0: c=0
    pause t1
    return
    ENABLE
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Code:
    Trisa = 32
    Trisc = 0
    
    
    a Var porta:c var portc
    x var word:x1 var word:x2 var word: x3 var word:t1 var word:
    
    dummy var byte
    
    
    t1=200
    
    ANSEL = 0
    ioca=%00100000
    CMCON0 = 7
    start:
    
    on interrupt goto flag
    INTCON = %10001000 
    
    one:
       
    
        gosub left
        goto one
        
    two:
    
    gosub all_on
    
    goto two
    
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    'SUBROUTINES
    disable
    flag:
    x=1+x
    x1=x//2
    if x1=0 then
    x2=1+x2
    x3=x2//2
    branch x3,[one_reset,two_reset] 
    endif
    dummy=porta  ; clear mismatch condition
    INTCON.0 = 0   ; reset interrupt flag 
    resume
    enable
    
    disable
    left:
    a=4:c=36
    pause t1
    a=0: c=0
    pause t1
    return
    enable
    
    disable
    all_on:
    a=7:c=63
    pause 100
    return
    enable
    
    one_reset:
    x=0
    goto one
    
    two_reset:
    x=0
    goto two
    We finally got it working! Thanks for all of your help, it was greatly appreciated.

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. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 18:14
  4. NEWBIE: Some basic questions using interrupts
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2006, 02:59
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 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