Confused by "on Interrupt"


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by retepsnikrep View Post
    OK thanks. Can anyone show me how to set up a simple interrupt as per my original post using DT Interrupts?
    hI retepsnikrep,
    Sorry for the delay. DT_INTS-14.bas Works excelently as is for all the 14 bit core PICs with ports defined as PortA, PortB . . . . I ran into a little snag porting it to the 12F series for GPIO on change in the port naming convention, and the fact they do not have RBC port to interrupt. I tried making appropriate changes in DT ints but got flag errors, so I took another tact which works. I added aliases in the P12F683.inc file of mpasm so as to give the compiler the belief that GPIO and PortB were the same.
    I added this to it in the area of INTCON Bits
    Code:
    RBIF                         EQU     H'0000' ; ADDED FOR dt INTS
    RBIE                         EQU     H'0003' ;ADDED
    This tells the assembler to act on RBIF as the same as GPIF and RBIE as GPIE .
    I didn't have a 683 so I compiled for a 683 and loaded into a 675, it works anyway, maybe Darrel has better ideas, this is what I was able to do.



    Code:
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
    DEFINE OSC 4
    Include "DT_INTS-14.bas"
    
    CMCON0 = 7             ' comparator pins configured as I/O
    ANSEL  = 0             ' all I/O as digital
    OSCCON = %01100000     ' 96 decimal 
    GPIO   = %00000000
    TRISIO = %00001000     ' GPIO Input all others as Outputs
    Option_Reg = %01000000 ' Interrupt on rising edge  INTEDG bit
    IOC = %00001000     ' Enable interrupt on change gpio.3
    i var byte
    Mainloop:
    ASM
    INT_LIST  macro        ; IntSource,  Label,             Type, ResetFlag?
            INT_Handler    RBC_INT,       _Do_This,   ASM,  no 
        endm
        INT_CREATE                   ; Creates the interrupt processor
    ENDASM
    
    @   INT_ENABLE   RBC_INT           ; enable external (INT) interrupts
    
    
    
    for i = 0 to 9
    GPIO.0 = 1
    pause 500
    gpio.0 = 0
    pause 500
    next i
    gpio = 0
    
    Goto Mainloop
    
    
    
    end
    
    Do_This:
    ;@ INT_DISABLE  RBC_INT
    gpio.1 = 1
    INTCON.0 = 0
    ;@ INT_ENABLE  RBC_INT
    goto mainloop
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  2. #2
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    That was nice of you to do that Joe.

    I think Darrel may have fixed that in his new version of interrupts. It is v1.00. You can find it at the bottom of this page:
    http://darreltaylor.com/DT_INTS-14/intro2.html

    It says it has GPC_INT -- GPIO Int On Change , among a bunch of other additions. But I have not played much with the DT-INTS-14 ... yet.

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scalerobotics View Post
    That was nice of you to do that Joe.

    I think Darrel may have fixed that in his new version of interrupts. It is v1.00. You can find it at the bottom of this page:
    http://darreltaylor.com/DT_INTS-14/intro2.html

    It says it has GPC_INT -- GPIO Int On Change , among a bunch of other additions. But I have not played much with the DT-INTS-14 ... yet.
    Thanks, I was still using ver .93, I will download the newer ver now. I am curious to see what I missed in my attempt. I got the defines and the ifdefs but couldn't figure out the flag handler.
    EDIT:
    Well Darrel's been busy ! Added GPIO and PortA interrupts too and it looks like a whole lot more. <font color=red>Thanks Darrel !,</font color>
    So using DT_INTS-14.bas ver 1.0
    Code:
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
    DEFINE OSC 4
    Include "DT_INTS-14.bas"
    
    CMCON0 = 7             ' comparator pins configured as I/O
    ANSEL  = 0             ' all I/O as digital
    OSCCON = %01100000     ' 96 decimal 
    GPIO   = %00000000
    TRISIO = %00001000     ' GPIO Input all others as Outputs
    Option_Reg = %01000000 ' Interrupt on rising edge  INTEDG bit
    IOC = %00001000     ' Enable interrupt on change gpio.3
    i var byte
    Mainloop:
    ASM
    INT_LIST  macro        ; IntSource,  Label,             Type, ResetFlag?
            INT_Handler    GPC_INT,       _Do_This,   ASM,  no 
        endm
        INT_CREATE                   ; Creates the interrupt processor
    ENDASM
    
    @   INT_ENABLE   GPC_INT           ; enable external (INT) interrupts
    
    
    
    for i = 0 to 9
    GPIO.0 = 1
    pause 500
    gpio.0 = 0
    pause 500
    next i
    gpio = 0
    
    Goto Mainloop
    
    
    
    end
    
    Do_This:
    gpio.1 = 1
    
    goto mainloop
    Do not forget to open DT_INTS and uncomment these 2 lines
    Code:
    wsave   VAR BYTE    $20     SYSTEM      ' location for W if in bank0
    wsave1  VAR BYTE    $A0     SYSTEM      ' location for W if in bank1
    Last edited by Archangel; - 13th January 2010 at 07:17.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Thanks that looks good.

Similar Threads

  1. Confused over A/D settings
    By malc-c in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd February 2010, 10:44
  2. 12C671 & Osccal register - I am confused
    By Megahertz in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th December 2009, 06:03
  3. confused problem with interrupt in a working program
    By illuminator4 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 14th November 2008, 17:01
  4. Hlp - newcomer getting confused
    By chunk in forum General
    Replies: 1
    Last Post: - 23rd January 2006, 18:47
  5. Problem with "on Interrupt" and PIC18F4620
    By philtep in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 21st September 2005, 02:24

Members who have read this thread : 0

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