Enable and Disable in Interrupts


Closed Thread
Results 1 to 4 of 4
  1. #1

    Post Enable and Disable in Interrupts

    Hello interrupt experts,

    I need some clarifications on Interrupts. I am reading a GREAT book on PicBasic called PicBasic Projecs by Dogan Ibrahim. He does explain the ENABLE and DISABLE commands but something doesn't make sense. Please look at the code below.

    'Main Program
    ON INTERRUPT GOTO XYZ
    **********
    *MAIN *
    *PROGRAM *
    *CODE *
    *HERE *
    **********

    DISABLE ' DISABLE INTERRUPTS
    XYZ:
    **********
    *INTERRUPT*
    *CODE *
    *HERE *
    **********
    RESUME 'RETURN TO CODE WHERE INTERRUPT OCCURRED
    ENABLE ' ALLOW INTERRUPTS TO HAPPEN


    This means that when an interrupt occurs (say a timer overflow) our program jumps to XYZ. Right?

    I understand why we do this. We don't want an interrupt, during an interrupt.

    My question is, shouldn't the DISABLE command go after the XYZ: label and the ENABLE COMMAND go before the RESUME command?

    The way it is written in my sample, when the program jumps to XYZ: the DISABLE is not executed. Also, When we exit the interrupt code with RESUME, the program doesn't execute the ENABLE. Kinda defeats the purpose. No?


    Thanx in advance.

  2. #2
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Forget the book

    Hi,

    You should really consider DT Instant interupt routines. They are easy to use and works instantly. The oldfashioned PBP way will not execute the interupt until after the command it is currently in is finished and that can be a long time if you just have entered a Pause_more_or_less_forever command.

    Search the forum and you will find all about it.

    /me

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    ENABLE and DISABLE are really compiler directives and NOT run-time program executable commands.

    What this means is that during COMPILE, additional code for checking and jumping to your PICBASIC interrupt will not be inserted between your code statements between the DISABLE and ENABLE pair. So the example you show is valid.

    The use of PICBASIC interrupts makes your program very code hungry (and slows it down) because of the way additional statements are inserted between your code, so the best way is only to have them enabled ONLY when you really want them. And because they don't get executed immediately (as can be now seen they're only jumped to BETWEEN your PICBASIC statements, this means that your PICBASIC commands will complete in the normal way BEFORE any interrupt jump is encountered... but if you understand what's going on inside your PIC you can handle this. Go search the forum for OLYMPIC TIMER for an example of PICBASIC interrupt usage.

  4. #4


    Did you find this post helpful? Yes | No

    Talking THAT'S WHAT I WANTED TO HEAR.... (read)

    Melanie,

    You you hit the nail on th head. That's what I wanted. It makes sense now. I just want to know and understand every line in my projects.

    Is there a list of these "compiler" directives anywhere?

    Thanks for the tip Jumper. I will look into it.


    Thanks for the en lighting answer.

Similar Threads

  1. Microcode studio - PIC16F877A Interrupts
    By mcbeasleyjr in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th January 2009, 07:10
  2. help: TMR0 interrupts disabling PORTAchange interrupts???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2008, 16:10
  3. 16F876A CCP1 Capture/Interrupt Question
    By TDonBass in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 17th January 2008, 04:25
  4. too many interrupts
    By trying in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd February 2006, 14:38
  5. Interrupts and Disable 16f877
    By Rob Martin in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 18th April 2005, 22:08

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