Interrupt On Change - question


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2007
    Posts
    67

    Default Interrupt On Change - question

    I'm playing with a 16F677 and have a question about interrupt on change.

    I'd like the pic to set a flag in the background when the pin changes, but I don't want to re-direct the program execution at all whenever that pin change happens. I'm afraid of using interrupts because I'm not sure what to predict of them.

    The data sheet says on pg. 62; 4.2.3 that the RABIF flag is set as soon as a mis-match happens. That's great, but is it going to interrupt the flow of my program? I don't want it to.

    I'm allowing a pin to see a signal spike that may or may not happen over time. I want to just run around and do some other stuff with my program, and when a timer runs out (which my program will check on its own), I want to go manually look at this RABIF flag to see if it got set while I was doing other stuff; then I'll read from the pin to clear the mis-match then clear the flag, and repeat the whole process.

    How do I handle this with the whole global interrupts thing? Anything special to code in picbasic?

    Thanks!

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


    Did you find this post helpful? Yes | No

    Default

    NOT a problem. And no interrupts required.

    As long as the Global Interrupt Enable is 0 (INTCON.7=0), the program flow will NOT be redirected on a change to to the IOC pins.

    The Interrupt flag (RABIF) will "Latch" on Any change, and the status will be available until the flag is cleared "Manually" in software. So you are free to "Poll" it at your leisure.

    If the condition goes away before the program gets around to looking at it, you can't tell which of the pins actually changed. Which could be a problem in itself, but it sounds like you may not need to know that.
    <br>
    DT

  3. #3
    Join Date
    Aug 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    you can't tell which of the pins actually changed. Which could be a problem in itself, but it sounds like you may not need to know that.
    <br>
    Oooohhh.... okay, well that sounds easy enough. I thought I could turn the interrupt on change on and off for individual pins. Is that only change to other pins on the port, or any pin on the entire pic?

    What if I have a pin set to an output and I'm driving it to do other stuff? That's the kind of "other" change that may happen while waiting for the input pin to trip. For example, I have 4 pins driving LED's as outputs, and my one pin set as an input is left to trip the flag?

    You've got me pointed in the right direction at least. Thanks!

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Only four pins on PortB have the interrupt on change capability and the interrupt is tripped when either one of those four changes state (if enabled). On the 16F677 you can enable/disable the interrupt on change feature for the four pins individually so if you only want one pin to trip the interrupt you simply enable the interrupt for that pin only. See section 4.4.2 in the datasheet for more info on how you do that.

    Older PICs like the 16F877 doesn't allow you to enable the interrupt for indvidual pins like you obviously can on the 16F677 - nice feature.

    HTH
    /Henrik.

  5. #5
    Join Date
    Aug 2007
    Posts
    67


    Did you find this post helpful? Yes | No

    Default

    Outstanding. Thanks so much. That makes my job easy.

Similar Threads

  1. A Simple IOC Routine (Interrupt On Change)
    By lugo.p in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th March 2010, 19:53
  2. Interrupt question
    By ultiblade in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 26th November 2009, 20:12
  3. 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
  4. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 18:14
  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 : 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