INTCON Register - GIE set to ON or OFF- same result: T0IE still works ?!


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891

    Default INTCON Register - GIE set to ON or OFF- same result: T0IE still works ?!

    Hi there,

    I'm making a simple countdown timer based on Melanie's Olympic Timer.

    Playing around with the register settings, I noticed that changing the GIE (INTCON.7) bit from 1 to 0 will not affect (apparently) the T0IE (INTCON.5) from working.

    Is this okay or shall I suspect something that will be affected (i.e. stop working) I'm not seeing today?
    Roger

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


    Did you find this post helpful? Yes | No

    Default Re: INTCON Register - GIE set to ON or OFF- same result: T0IE still works ?!

    Melanie's Olympic code uses ON INTERRUPT, so you cannot change the GIE bit manually.

    Clearing GIE tells PBP that an interrupt has occured and it will be processed immediately. Even though no interrupts actually triggered.
    GIE will then be SET again, looking like it was never cleared to begin with.

    If you don't want a section of code to be interrupted, wrap it with DISABLE INTERRUPT/ENABLE INTERRUPT.
    DT

  3. #3
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default Re: INTCON Register - GIE set to ON or OFF- same result: T0IE still works ?!

    So this explains why the Interrupt is still working even if I set INTCON.7 = 0 ;-)

    The DS of my PIC says:
    GIE: Global Interrupt Enable bit (bit 7)
    1 = Enables all unmasked interrupts
    0 = Disables all interrupts

    Nevertheless, voici what is stated in (page 118 of) the 2008 PBP manual:
    -" To turn off interrupts permanently (or until needed again) once ON INTERRUPT has been used, set INTCON to $80: INTCON = $80 "-

    To me, setting INTCON = $80 is like %10000000 meaning the interrupts are switched ON.

    Am I mixing things or is there somewhere an error?
    Roger

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


    Did you find this post helpful? Yes | No

    Default Re: INTCON Register - GIE set to ON or OFF- same result: T0IE still works ?!

    Quote Originally Posted by flotulopex View Post
    To me, setting INTCON = $80 is like 000000 meaning the interrupts are switched ON.
    Setting it to $80 does keep the "Global Enable" (GIE, INTCON.7) enabled, and this is required to keep ON INTERRUPT from thinking an interrupt occured.
    But it also clears the "Peripheral Interrupt Enable" (PEIE, INTCON.6), so no peripherals can trigger an interrupt.

    The manual should have added to disable the interrupts that are not "Peripheral" like TMR0 and the INT pin, but it didn't.
    *Added* Or I guess it did, T0IE and INTE are in INTCON in the 16F's, so clearing INTCON would also clear them.
    *Added* But with 18F's there are more non-peripheral interrupts like INT2IE in INTCON3.

    The PBP3 manual has expanded the information on interrupts, and the $80 statement isn't there anymore.
    It recommends clearing each enable bit for all interrupts being used.
    It also describes DISABLE INTERRUPT and ENABLE INTERRUPT.

    But there are two ways of thinking about it, and your application dictates which method to use.

    Clearing the enable bits allows a section of code or the entire program to proceed without being interrupted, but it still checks between every line of code for an interrupt. Which does allow for selective disabling of individual interrupts.

    Using DISABLE INTERRUPT/ENABLE INTERRUPT stops the checking between each line which makes that section run faster and use less code space.
    DISABLE/ENABLE only affects the code it surrounds and can't turn interrupts off for the whole program.

    The method used really depends on what your program needs.

    HTH,
    Last edited by Darrel Taylor; - 30th May 2012 at 04:55. Reason: *Added*
    DT

  5. #5
    Join Date
    Aug 2006
    Location
    SWITZERLAND (french speaking)
    Posts
    891


    Did you find this post helpful? Yes | No

    Default Re: INTCON Register - GIE set to ON or OFF- same result: T0IE still works ?!

    Thanks a lot Darrel.
    Roger

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