interrupt with 16F88


Closed Thread
Results 1 to 7 of 7

Hybrid View

  1. #1
    Join Date
    Mar 2008
    Location
    london
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    General code flow when using ON_INTERRUPT's...(you mileage may vary, others do it other ways, I do it this way)...

    1) resetplaceholder: 'just a placeholder

    2) ------DEFINEs needed thru the program

    3) DISABLE 'need to disable interrupts while actually processing an interrupt

    4) CLEAR

    5) ------any eeprom data, variable definitions, etc.

    6) ------macro's you might be using

    7) startupholder: goto skipsubs 'skip over all the commonly used subroutines

    8) ON INTERRUPT GOTO INTHANDLER

    9) INTHANDLER: 'process your interrupts.

    10) 'check the interrupt bits, if the interrupt you want is active, reset the bit and process it

    11) INTFINISH: 'I usually recheck the interrupt sources. If one of them tripped while I was processing a previous interrupt, I go back and re-process the interrupt

    12) INTRESUME: RESUME 'resume AFTER you've processed the interrupt

    13) 'commonly used subroutines start below here

    14) commonly_used_sub_1: 'do something here and return from it

    15) ..........

    16) 'end of commonly used subroutines, skipsubs block for setting up registers, lcd, whatever

    17) skipsubs: 'set up the PIC as required

    18) mainloop: 'the main program runs here waiting to get interrupted

    19) ------------more program stuffed in here.........

    20) goto mainloop

    21) END

    hello,
    i wanted to test an interrupt in a simple small code , i found a code on the internet and modified it and got this:
    @ DEVICE INTRC_OSC, LVP_OFF, WDT_OFF, MCLR_OFF

    DEFINE OSC 4

    OSCCON=%01101000 ' INTRC = 8MHz
    ANSEL=%00000000
    CMCON=%00000111


    OPTION_REG.6=1 'Trigger on rising edge
    INTCON = %10010000 'Enable INTE
    INTCON.1 = 0 'Clear RB0/INT External Interrupt Flag bit

    On Interrupt Goto UpdateCounter

    PORTB=0 ' PORTBs are outputs
    Pause 500 ' Wait for startup
    'LOW PORTB.6

    loop:
    low portb.6
    HIGH PORTB.5
    Pause 2000 ' Wait 2 second

    low portb.6
    LOW PORTB.5
    Pause 2000 ' Wait 2 second
    Goto loop ' Do it forever

    Disable
    UpdateCounter:
    LOW PORTB.5
    HIGH PORTB.6
    pause 500
    low portb.5
    LOW PORTB.6
    pause 500

    INTCON.1=0 're-enable interrupts

    resume
    ENABLE
    GOTO loop

    END


    the code works, but the interrupt routine doesn't work, doesn t light the led connected to pin portb.6.
    I mean when the portb.0 is connected to ground the led connected to portb.5 blinks as soon as i connect the portb.0 to +5v the portb.5 stops to blink and nothing happens to portb.6 led.
    can you help me on that please???
    how can I use a digital signal to activate the interrupt for example, with an if statement??

    if portb.0 = 1 , the interrupt is activated and the program jumps to the int subroutine and if portb.0 = 0 the program comes back to the main loop???????

    thank you

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    And yet again, one very important step is missing and one not so important step is also not present...
    No, your code doesn't follow my example exactly, and no, it doesn't have to follow it exactly. Mine is only an example, one of many ways to accomplish the same thing.
    However, I believe in this case, if you follow the example provided, and write your code following said example, you will solve your problem.
    And no, I'm not playing games with you...

Similar Threads

  1. 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
  2. 16f88 interrupt
    By tur_bot in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 2nd April 2008, 12:35
  3. 16F88 Interrupt
    By sskeet in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 24th January 2006, 16:51
  4. How to use an Interrupt to drive a menu on 16f88
    By Tom Gonser in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 15th March 2005, 02:16
  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