Understanding Interrupts


Closed Thread
Results 1 to 11 of 11
  1. #1
    Join Date
    Oct 2007
    Posts
    26

    Default Understanding Interrupts

    Greetings All

    I have managed to get an interrupt working in my program but don't fully understand it all.
    It is a very simple interrupt that activates when RB0 is taken low. Pretty much out of the PBP manual.

    Here is the Code that Matters:

    OPTION_REG = $7f
    On Interrupt Goto myint ' Define interrupt handler
    INTCON = $90 ' Enable RB0 interrupt

    Disable ' No interrupts past this point
    myint:
    Stuff happens here ......
    INTCON.1 = 0 ' Clear interrupt flag
    Resume ' Return to main program
    Enable

    My Questions Are:

    OPTION_REG = $7f was in the original example I used but it seems to work fine without it. What does this do? Do I need it?
    How would I create a second Interrupt say when RB1 is taken low.
    $90 is %10010000 therefore is the fourth 1 the bit that refers to RB0
    When I clear the flag INTCON.1 = 0 what exactly is going on here.
    If Resume Returns to the main program I take it Enable never gets run.

    Can anyone help me understand Interrupts better.

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


    Did you find this post helpful? Yes | No

    Default

    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.

  3. #3
    Join Date
    Oct 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Deeper Understanding

    I am sorry to say the thread http://www.picbasic.co.uk/forum/showthread.php?t=6444 got me even more confused and I ended up with just a bunch more questions. However, the good news is that it made me search for more information. I ended up looking at this thread: http://www.picbasic.co.uk/forum/showthread.php?t=3251 and on to Darrel Taylors Wesite: http://darreltaylor.com/DT_INTS-18/home.html

    So for others New to this and struggling with concept of interrupts my advice would be to check these two links out. I found it well documented and easier to understand than a bunch of other stuff I had struggled with for several nights. It certainly helped me heaps. My personal thanks goes out to Darrel Taylor

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


    Did you find this post helpful? Yes | No

    Default

    Woohoo!

    Newbus Interruptus.

    One of the times you Like stopping what you were doing.
    <br>
    DT

  5. #5
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default

    lol ...

    Well, they say that one of the best definitions for an interrupt is a telephone. If the phone's ringer was to be replaced with a LED -- you'd have to constantly glance at it once in a while to see if someone was calling you. Arguably, you'd never get any work done (certainly not as much) So, I guess this is comparable to continuously polling an input on a PIC. Here's a thought; could something be used to replace the ringer having an equal or better interrupt effect?

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


    Did you find this post helpful? Yes | No

    Default

    Newbus Interruptus

    There once was a newbie, that couldn't Interrupt.
    Can't blame him, it's a hard thing to do.

    He knows that he must, and with every thrust
    his results have been proven un-true.

    It's turmoil at home.
    The thoughts of the Cost.
    and the sleepless nights ahead.

    He searches the forum,
    and ignores the decorum, until his eyes were red.

    He searches some more, it's really a bore,
    and happens across a new thread.

    It promises Interrupts, and sanity,
    without all of the dread.

    He tries with success,
    and ceases distress,
    and is ready to mount the new task.

    Ha, and it worked.
    <hr>

    Uhh, you were saying something about telephones?
    DT

  7. #7
    T.Jackson's Avatar
    T.Jackson Guest


    Did you find this post helpful? Yes | No

    Default

    Darrel,

    Don't quit the pics

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


    Did you find this post helpful? Yes | No

    Default

    hey,

    There's a writers strike in california right now.

    I gotta come up with it on my own.
    <br>
    DT

  9. #9
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    hey,

    There's a writers strike in california right now.

    I gotta come up with it on my own.
    <br>
    Darrel,

    This is what you need:

    www.poetry.com
    I am already in semi-finals.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  10. #10
    Join Date
    Oct 2007
    Posts
    26


    Did you find this post helpful? Yes | No

    Default

    Talking about LED's and Telephones and seeing you are all turning my thread into a comedy section I thought I would add to the mix ...

    Reminded me of an incredibly funny segment from a comedy show I saw years ago...

    It was highlighting an invention for deaf people so they would know when the phone rang. Basically they wore a device on the head which flashed an LED when their phone rang. Initially you thought what a great Idea until it actually flashed and the DEAF person wandered over and answered the phone. "HELLO, HELLO is anyone there ..... HELLO HELLO ..... HELLO ...."

    On the same vain the interrupt for the blind sky diver, so that he knows when to pull the rip cord, is when the lead to the seeing eye dog goes slack.

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


    Did you find this post helpful? Yes | No

    Default

    That's the Spirit!

    Although I now have some disturbing mental images of how that ends up.

    DT

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 22:14
  2. Continuous Interrupts when using DT_INTS and an INCLUDE file
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 15th January 2010, 21:42
  3. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  4. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 20:48
  5. help: TMR0 interrupts disabling PORTAchange interrupts???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2008, 15:10

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