interrupts - basic info needed


Closed Thread
Results 1 to 4 of 4
  1. #1
    malc-c's Avatar
    malc-c Guest

    Default interrupts - basic info needed

    Been reading up in interrupts and I'm still confused. From what I've read you can have several interrupts and they basically allow you to run something simultaneously whilst the main program continues from the point it was interrupted. Is this like the gosub command ?

    I noted that it states that pause etc can delay the resume so what would be the difference in something like the following?

    Code:
    main:
    pin goes high
    pause 2000
    pin goes low
    display the time on an LCD
    and
    Code:
    main:
    interrupt one
    display the time on LCD
    
    interrupt one:
    pin goes high
    pause 2000
    pin goes low
    resume
    in the second bit of code, would the pin be high whilst the time is shown on the LCD ? or would it wait for the pin to go low before resuming back to the main part of the program... ??

    Sorry if this is very basic, but I've never written a routine with interrupts.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Generally speaking, when an interrupt occurs the main program execution stops, jumps to the interrupts service routine, executes the code that's in it and then jumps back and continues executing the main program where it left it. The main program does NOT continue WHILE the code in the interrupt service routine is executed.

    So in your second program the the LCD would stop updating while the interrupt is serviced and then continue.

    /Henrik.

  3. #3
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Thanks very much for the explanation.

    So is an interrupt the same as gosub, in that it jumps out to a routine and then jumps back ?

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


    Did you find this post helpful? Yes | No

    Default

    Yes it is.

Similar Threads

  1. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  2. using AND as an IF statement
    By dw_pic in forum mel PIC BASIC
    Replies: 27
    Last Post: - 8th June 2006, 18:05
  3. NEWBIE: Some basic questions using interrupts
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2006, 02:59
  4. Instant interrupts in Basic?
    By Bulman in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 6th January 2006, 11:53
  5. ASM Interrupts with BASIC code?
    By Desterline in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 31st October 2003, 19:21

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