Instant Interrupts - Revisited


Closed Thread
Results 1 to 40 of 773

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    So far I've shown one interrupt source being used at a time, but as I said in the first post, you can easily service Multiple Interrupt Sources.   So what if we wanted to join the previous 3 examples into one program.   NOT a problem!

    To add more interrupt "Handlers", simply add them to the INT_LIST, and create a subroutine for them.

    Since both the Blinky Light, and Elapsed Timer used TMR1, lets move the Blinky Light over to TMR0. Elapsed will still use TMR1.
    Code:
    <font color="#000000"><b>LED1   </b><font color="#008000"><b>VAR  </b></font><b>PORTD</b>.<b>0
    LED2   </b><font color="#008000"><b>VAR  </b></font><b>PORTD</b>.<b>1
    
    </b><font color="#008000"><b>INCLUDE </b></font><font color="#FF0000">&quot;DT_INTS-14.bas&quot;     </font><font color="#0000FF"><b><i>' Base Interrupt System
    </i></b></font><font color="#008000"><b>INCLUDE </b></font><font color="#FF0000">&quot;ReEnterPBP.bas&quot;     </font><font color="#0000FF"><b><i>' Include if using PBP interrupts
    </i></b></font><font color="#008000"><b>INCLUDE </b></font><font color="#FF0000">&quot;Elapsed_INT.bas&quot;    </font><font color="#0000FF"><b><i>' Elapsed Timer Routines
    
    </i></b></font><font color="#008000"><b>ASM
    </b></font><font color="#000080">INT_LIST  macro    </font><font color="#0000FF"><b><i>; IntSource,        Label,  Type, ResetFlag?
            </i></b></font><font color="#000080">INT_Handler    INT_INT,  _ToggleLED1,   PBP,  yes
            INT_Handler   TMR0_INT,  _ToggleLED2,   PBP,  yes
            INT_Handler   TMR1_INT,  _ClockCount,   PBP,  yes
        endm
        INT_CREATE               </font><font color="#0000FF"><b><i>; Creates the interrupt processor
    
        </i></b></font><font color="#000080">INT_ENABLE   INT_INT     </font><font color="#0000FF"><b><i>; enable external (INT) interrupts
        </i></b></font><font color="#000080">INT_ENABLE  TMR0_INT     </font><font color="#0000FF"><b><i>; enable Timer 0 interrupts
        </i></b></font><font color="#000080">INT_ENABLE  TMR1_INT     </font><font color="#0000FF"><b><i>; Enable Timer 1 Interrupts  
    </i></b></font><font color="#008000"><b>ENDASM
    
    </b></font><b>OPTION_REG </b>= <b>OPTION_REG </b>&amp; <b>$80 </b>| <b>1  </b><font color="#0000FF"><b><i>; Set TMR0 Prescaler to 256, leave RBPU alone
    </i></b></font><font color="#008000"><b>GOSUB </b></font><b>ResetTime              </b><font color="#0000FF"><b><i>' Reset Time to  0d-00:00:00.00
    </i></b></font><font color="#008000"><b>GOSUB </b></font><b>StartTimer             </b><font color="#0000FF"><b><i>' Start the Elapsed Timer
    
    </i></b></font><b>Main</b>:
        <font color="#008000"><b>IF </b></font><b>SecondsChanged </b>= <b>1 </b><font color="#008000"><b>THEN  
           </b></font><b>SecondsChanged </b>= <b>0
           </b><font color="#008000"><b>LCDOUT </b></font><b>$FE</b>,<b>$C0</b>, <font color="#008000"><b>DEC </b></font><b>Days</b>,<font color="#FF0000">&quot;d-&quot;</font>,<font color="#008000"><b>DEC2 </b></font><b>Hours</b>,<font color="#FF0000">&quot;:&quot;</font>,<font color="#008000"><b>DEC2 </b></font><b>Minutes</b>,<font color="#FF0000">&quot;:&quot;</font>,<font color="#008000"><b>DEC2 </b></font><b>Seconds
        </b><font color="#008000"><b>ENDIF
    GOTO </b></font><b>Main
    
    </b><font color="#0000FF"><b><i>'---[INT - interrupt handler]---------------------------------------------------
    </i></b></font><b>ToggleLED1</b>:
         <font color="#008000"><b>TOGGLE </b></font><b>LED1
    </b><font color="#000080">@ INT_RETURN
    
    </font><font color="#0000FF"><b><i>'---[TMR0 - interrupt handler]-------------------------------(Blinky Light)------
    </i></b></font><b>T0Count  </b><font color="#008000"><b>VAR WORD
    </b></font><b>ToggleLED2</b>:
        <b>T0Count </b>= <b>T0Count </b>+ <b>1
        </b><font color="#008000"><b>IF </b></font><b>T0Count </b>= <b>512 </b><font color="#008000"><b>THEN </b></font><b>T0Count </b>= <b>0 </b>: <font color="#008000"><b>TOGGLE </b></font><b>LED2
    </b><font color="#000080">@ INT_RETURN
    </font>
    <font size=-2>Code Size = 711 Words</font>

    Now we have all three interrupt sources working together in the same program.
    LED1 responds to the external INT
    LED2 flashes, timed by TMR0
    and, the elapsed timer is maintained via TMR1
    And, all of this is happening behind the scenes of your normal PBP program.
    I test for 16f877a and it's work.
    But for the 18f88 i got the message : Symbol not previously defined (T0IF)
    and not compile.Why;

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    I test for 16f877a and it's work.
    But for the 18f88 i got the message : Symbol not previously defined (T0IF)
    and not compile.Why;
    That would be a good trick....compiling for an 18F88. I can't seem to find it on the Microchip website.

    Try TMR0IF (a zero after TMR). Or you don't have an up-to-date version of PBP.

    Previous Release: 2.45

    * Adds support for PIC12F508, 509, 683, PIC16F505, 684, 688, 716, 737, 747, 767, 777, 87, 88, PIC18F2331, 2431, 2515, 2525, 2585, 2610, 2620, 2680, 4331, 4431, 4515, 4525, 4585, 4610, 4620, 4680, 6410, 6490, 8410 and 8490.

  3. #3
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post

    Previous Release: 2.45

    * Adds support for PIC12F508, 509, 683, PIC16F505, 684, 688, 716, 737, 747, 767, 777, 87, 88, PIC18F2331, 2431, 2515, 2525, 2585, 2610, 2620, 2680, 4331, 4431, 4515, 4525, 4585, 4610, 4620, 4680, 6410, 6490, 8410 and 8490.
    I have 2.46

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by savnik View Post
    I have 2.46
    Well, if TMR0IF (or T0IF for that matter) doesn't work, then just change the code to access the interrupt flag bit directly from the applicable register.

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


    Did you find this post helpful? Yes | No

    Default

    Microchip can't make up thier mind on what they want to call things. In most 16F's it's called T0IF, and in the 18F's it's TMR0IF, but for some reason, in a 16F88 it's also called TMR0IF. It's the same with the T0IE/TMR0IE.

    Fortunately, we aren't stuck with whatever they decide to call things.

    Just add the 2 highlighted lines, and you should be fine. (no spaces before them)
    Code:
    ASM
    T0IF = TMR0IF
    T0IE = TMR0IE
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    INT_INT,  _ToggleLED1,   PBP,  yes
            INT_Handler   TMR0_INT,  _ToggleLED2,   PBP,  yes
            INT_Handler   TMR1_INT,  _ClockCount,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    
        INT_ENABLE   INT_INT     ; enable external (INT) interrupts
        INT_ENABLE  TMR0_INT     ; enable Timer 0 interrupts
        INT_ENABLE  TMR1_INT     ; Enable Timer 1 Interrupts  
    ENDASM
    DT

  6. #6
    Join Date
    Jun 2006
    Location
    Greece
    Posts
    302


    Did you find this post helpful? Yes | No

    Smile

    Thank you.
    Now it's work.

Similar Threads

  1. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  2. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 20:02
  3. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 20:48
  4. Keypad and DT's Instant Interrupts
    By Homerclese in forum General
    Replies: 11
    Last Post: - 27th April 2007, 06:32
  5. Replies: 1
    Last Post: - 1st November 2006, 03:11

Members who have read this thread : 5

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts