Interrupt 101


Closed Thread
Results 1 to 17 of 17

Thread: Interrupt 101

Hybrid View

  1. #1
    Join Date
    Sep 2007
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: Interrupt 101

    Okay, I've been looking at Daryl Taylors interrupt programs as recommended by Steve. I downloaded everything and tested the blinky blinky to make sure it worked. I changed the toggle pin to one on my board with an LED and it worked.

    Now I'm trying to figure out how to incorporate this into my program and what terms I can change and what I can't and where it needs to be placed in the program. I don't have anything called a "main" loop for example.

    So for example with this sample code:
    Code:
     
    LED1   VAR  PORTB.1
     
    INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
     
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    INT_INT,  _ToggleLED1,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
     
    @   INT_ENABLE   INT_INT     ; enable external (INT) interrupts
     
    Main:
      PAUSE 1
    GOTO Main
     
    '---[INT - interrupt handler]---------------------------------------------------
    ToggleLED1:
         TOGGLE LED1
    @ INT_RETURN
    I understand that the "include" statements go at the top when declaring stuff but I'm not sure where to put the "ASM" section
    and the "INT" Interrupt handler commands

    I tried a couple things and the blinky blinky always worked but I never got my part of the program to run so it seemed to only stay in the above portion.

    Getting closer, I can smell it, but I can't quite see it or taste it.
    Thank you,
    Hylan

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Interrupt 101

    In the example you have posted place your code in the "Main" loop. To start try a PAUSE type blink in the Main loop to seehow ot works.
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2007
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: Interrupt 101

    Beautiful! I've got the interrupt working properly on the one pin. Now I can start playing with all the other layers and types. I'm sure I will have more questions but at least I've got a starting point.
    Thank you!
    Hylan

  4. #4
    Join Date
    Sep 2007
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: Interrupt 101

    I'm finally back looking at this again and would like to use the RX2 pin as the interrupt trigger when a serial string comes in on my 18F6520 chip.
    I'm currently using a hserin command and just running it in my main loop to pick up new signals and 999/1000 it works fine.
    I'm looking through pic manual but it's pretty Greek to me.
    Does anyone have an example of how to configure this for the RX2 pin?
    Thank you,
    Hylan

  5. #5
    Join Date
    Sep 2007
    Posts
    59


    Did you find this post helpful? Yes | No

    Default Re: Interrupt 101

    I did a search and think I found some examples, sorry for the premature post.

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Interrupt 101

    Here is a snippet of running code


    Code:
     
    
    INTCON = %11000000
    
    '---------------------------------------------
    
        INCLUDE "DT_INTS-18.bas"         
        INCLUDE "ReEnterPBP-18.bas"    
      
    ASM
    INT_LIST  macro     
    
                INT_Handler    RX2_INT,    _GetCharPort2,    PBP,  yes
    
            endm
        INT_CREATE      
    ENDASM
    ;----------------------------------------------------------------------------------                         
    Goto OverInt
    
    
    GetCharPort2:
        
        for I_XDataLen = 0 to 63
            HSERIN2 50,TimeOut2,[I_XDataChar]
            if I_XDataChar = 13 then goto GetChar2Valid
            I_XDataBuf[I_XDataLen] = I_XDataChar
        next I_XDataLen
        I_XDataLen = 63 ' lost characters, but do the best we can
    GetChar2Valid:
    Timeout2:
        I_XDataBuf[I_XDataLen] = 0
        if I_XDataLen > 0 then
            XDataSource = 2
            XDataFlag = 1
        endif
    GetChar2_Return:
        if PIR3.5 then HSERIN2 [I_XDataChar]
    @ INT_RETURN
    ;--------------------------------------------------------------------
    
    Overint:
    
      PIR3.5 = 0
    @ INT_ENABLE RX2_INT
    
    YOUR CODE HERE
    Charles Linquist

Members who have read this thread : 0

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