Interrupt usage


Results 1 to 10 of 10

Thread: Interrupt usage

Threaded View

  1. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    i see quite a few mistake here
    1. there's no Goto Start after your LED blink
    2. Disable INTERRUPT is not placed at the right place
    3. you can't have more than 1 ON INTERRUPT GOTO
    4. the first ON INTERRUPT is not a the right place
    5. not sure about the NAP loop... to me PAUSEUS would be a better option
    6. not sure about SLEEP in the ISR
    7. yes you MUST clear INT flag
    8. There's no RESUME at the end of your ISR
    9. WAIT is a reserved word and can't be used for labels

    but the rest is OK

    Something like bellow should work
    Code:
        @ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON
    
        CMCON = 7               ' SETS DIGITAL MODE
        ANSEL = 0               ' GPIO.0 TO GPIO.3 SET AS DIGITAL
    
        OPTION_REG = 0          ' WEAK PULLUPS ENABLED
                                ' GP2/INT on falling edge
                                
        TRISIO = %00000100      ' GPIO.2 SET AS INPUT
    
        GPIO = 0
    
        N VAR BYTE              ' VARIABLE N DEFINED
        
        ON INTERRUPT GOTO WAIT_int    
        INTCON = %10010000      ' INTERRUPT ENABLED
    
      '  *************************************************************
    START:
                TOGGLE GPIO.0
                FOR N=0 TO 250
                    pauseus 1000
                    NEXT
                GOTO START
                         
    DISABLE        
    WAIT_INT:
                TOGGLE GPIO.1
                INTCON.1=0      ' Clear GP2/INT flag
                RESUME
                ENABLE
                
                END
    Last edited by mister_e; - 9th April 2008 at 05:10.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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