Why use Interrupts


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default Why use Interrupts

    Hi,

    I have not work with interrupts yet, But I heard different stories on them. Some say they are useful, other say they don't use them and rather trouble shoot in real time.
    I would just like to have your opinion on this

    thanks
    ken

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by lerameur View Post
    Hi,
    I have not work with interrupts yet, But I heard different stories on them. Some say they are useful, other say they don't use them and rather trouble shoot in real time. I would just like to have your opinion on this
    thanks
    ken
    In my case, real programming example...(as opposed to a fake one? )
    Multiple channel software based PWM for lighting along with serial port control. Almost impossible to do with just a loop and keep all the light intensities the same, nevermind trying to read the serial port while you're controlling all the lights.

    So, enter the lowly 'interrupt'...

    The timer fires an interrupt and I update the outputs according to the PWM counter and duty cycle registers...

    The serial port fires an interrupt telling me that I've received a byte across the serial port. If I didn't use an interrupt and had been processing a few lines for controlling the lights, I might've missed that byte. With the interrupt, I can save it in a buffer and act on it when I'm ready.

    And the whole time, my main loop is executing (except when I'm in the interrupt routine, which is 'in and out' as fast as possible), I'm updating duty cycle registers according to the latest data received over the serial port, I'm checking push buttons, keeping tabs on power, sending a few bytes back out the serial port, whatever.

    Another simple example...If you didn't have interrupts on your PC, the clock wouldn't get updated along with a million other things.
    For example, you might be playing a flight simulator and the CPU was busy doing some calculations for the aircraft in flight, you hit the button for flaps, but the program was busy crunching numbers and missed the button push...because it doesn't have interrupts. But, since a PC does have interrupts, the program was able to jump away from the main loop for a split second, save the keypress in a buffer somewhere, and go back to the main loop (but you don't notice because the interrupt subroutine is just long enough to do what it has to do). Then when the program got finished crunching a few numbers, it checked the buffer that holds keypresses, and found the keypress for the flaps...now your flaps are down (or up...whatever).

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


    Did you find this post helpful? Yes | No

    Default

    i think the problem is back of the keyboard or a total misunderstanding of them rather than else.

    Yes they are usefull, but every project are different. Hard to say, when you need, and when you don't.

    TIMER interrupt is soooo useful to me. PushButton scan, Debounce, TRIS refresh, USBSERVICE, etc etc
    Last edited by mister_e; - 11th May 2007 at 23:14.
    Steve

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

  4. #4
    Join Date
    Jan 2007
    Posts
    37


    Did you find this post helpful? Yes | No

    Default

    How can I learn about interrupts ?

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


    Did you find this post helpful? Yes | No

    Default

    well, i don't want to sounds like a broken record, but Doing a Forum search with interrupt as keyword will lead you to several thread.

    Datasheet will show you all interrupt source for your PIC (timer, USART, MSSP, interrupt on PORTB change, INT0, INT1 etc etc )
    Steve

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

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 22:14
  2. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  3. Microcode studio - PIC16F877A Interrupts
    By mcbeasleyjr in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th January 2009, 06:10
  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