Disable/Enable in Interrupts


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795

    Default Disable/Enable in Interrupts

    If I have a group of Subroutines on top of my program and don't want these to be interrupted, can only one Disable on top and Enable on bottom be enough? Or every sub must have their own pair?

    Is this correct:

    On Interrupt Goto myint

    Disable
    Sub1
    Return

    Sub2
    Return
    Enable

    Disable
    myint:
    Resume
    Enable

    main:
    'my main loop with interrupts enabled
    End

    Thanks, Ioannis

  2. #2
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Hopefully Yes

    Hi,

    The Enable/Disable are compiler directives which does or does not put the PBP int checking codes into you routine. So this should work. Remember strictly for PBP interrupts. Another way is to turn off the individual interrupt settings only keeping the Global INT turned on i.e., INTCON = $80. If you have other peripheral interrupts then they should be turned off too. (By only clearing the PIE bits perhaps) Mention your PIC and interrupts used.
    Regards

    Sougata

  3. #3
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default Disable/Enable in Interrupts

    Thanks for the reply.

    The PIC is 16F877 and interrupts are coming from the UART module.

    My concern is if the disable directive needs to be inserted in every subroutine. Logicaly not as it is directive and covers all the block of commands until it finds the Enable pair.

    Ioannis

  4. #4
    Join Date
    Apr 2013
    Posts
    32


    Did you find this post helpful? Yes | No

    Default Re: Disable/Enable in Interrupts

    This would also work but I think it would cause problems for you. For example;
    if you call sub2 before calling sub1, then interrupts wont be disabled
    if you call sub1 and return to main, then again interrupts wont be enabled until you call sub 2

    So my suggestion is to disable - enable interrupts on each subroutine individually.

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default Re: Disable/Enable in Interrupts

    Thanks, although back from the dead!



    Ioannis

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 23: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, 22:42
  3. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 22:43
  4. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 21:48
  5. help: TMR0 interrupts disabling PORTAchange interrupts???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2008, 16:10

Members who have read this thread : 2

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