Handling External/Timer Interrupts


Closed Thread
Results 1 to 2 of 2
  1. #1
    Tacky3000's Avatar
    Tacky3000 Guest

    Default Handling External/Timer Interrupts

    Hello all,

    On a PIC16F627A:

    Looking for some advice on how to simultaneously handle an external interrupt on RB0 as well as a timer. I am kind of new to this whole interrupt thing, and from my research I have no idea how to differentiate between which interrupt has triggered.

    From what I know thus far:
    External Interrupt on RB0:
    -Set INTCON = %10010000
    -have line of code "On interrupt goto myint"
    -end myint with resume
    -wrap myint with command disable and enable (to disable/enable any other interrutps)

    I believe once you do this, when RB0 goes high it will execute code in myint - correct?

    And now for the timer0 (will likely need a 10 second timer) -
    To set up (using 4MHz):
    -Prescaler should be 1 so "0b000" (longest time between ticks)
    -Start TMR0 at 0h00
    -Need to set appropiate enable flag in INTCON

    So now here's where I am confused:
    A) How do I find out how many ticks I need for approximately 10 seconds?

    B) How do I know what will happen when timer overflows? Will nothing happen - in this case I need to poll the timer flag and when it overflows then take appropriate action?

    C) If an external interrupt occurs, it will execute instructions with interrupts disabled, does this mean the timer will halt? Anything need to be done to start it up again?

    D) Kind of related to (C), what needs to be done each time the timer overflows to restart the event? Reset TMR0 to 0h00 and clear the flag in INTCON?


    Thanks for any and all help!

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    First of all, I see you are new here. Welcome.

    To handle interrupts, I suggest you look for Darrell Taylor's excellent posts on Instant Interrupts. They are a hit here you see. Moreover, they will avoid the code bloat and latency that ON INTERRUPT processing offers. Just looking through the posts on instant interrupts will reveal a lot of ideas on how to solve your problem.

Similar Threads

  1. 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
  2. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  3. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 20:48
  4. help: TMR0 interrupts disabling PORTAchange interrupts???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2008, 15:10
  5. Interrupts Identification (handling)
    By RodSTAR in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 21st April 2008, 13:40

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