Instant Interrupts - Revisited


Closed Thread
Results 1 to 40 of 773

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Just wondering if doing something like this is a 'no no' wrt to the interrupt handlers...

    Code:
    CPM1_Interrupt_Handler:
    
    @ INT_DISABLE  CMP1_INT
    [do some stuff here]
    @ INT_ENABLE  CMP2_INT
    
    @ INT_RETURN
    
    
    CPM2_Interrupt_Handler:
    
    @ INT_DISABLE  CMP2_INT
    [do some stuff here]
    @ INT_ENABLE  CMP1_INT
    
    @ INT_RETURN
    ....essentially 'toggling' between each comparator being 'interrupt' enabled (& where the other comparator enables/disables itself & its partner). I'm getting weird results, but that's probably cos the rest of my code isn't robust - but just wanted to establish if it's ok to do this (especially if the comparators are interrupting rapidly due to them both rx'ing a rapidly changing input - and also each comparator potentially interrupting very closely in time)

    Also, not having a clue about this kinda stuff, just wondering what's going on 'under the hood' so to speak....ie when an interrupt enable &/or disable is actioned as per the above? (does enabling/disabling in such a manner use a lot of processor clock cycles? Or is it pretty swift?)

    Thanks.
    Last edited by HankMcSpank; - 12th September 2010 at 18:24.

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


    Did you find this post helpful? Yes | No

    Default

    Nothing wrong there.

    There are two different actions that can change the way INT_ENABLE works with version 1.10.

    DEFINE INT_ENABLECLEARFIRST 1 ; (default)
    With the above define, which is also the default, whenever you INT_ENABLE, the flag is automatically cleared before the interrupt is enabled.

    DEFINE INT_ENABLECLEARFIRST 0
    Whith this define, the flag is NOT cleared.
    This can dramatically change the results and cause immediate interrupts if the flag is already set.

    If INT_ENABLECLEARFIRST is 0, then INT_ENABLE takes one instruction cycle.
    If INT_ENABLECLEARFIRST is 1, then INT_ENABLE takes two instruction cycles.

    INT_DISABLE always takes one instruction.
    DT

  3. #3
    Join Date
    Sep 2010
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    hi all, i face a problem here.

    why when im trying to compile the dt_ints-18 file without changing anything, it shows

    Error[113] c:\picbas~1.47\pbppic18.lib 1170 : symbol not previously defined (int_entry_H)

    im using 18f2680

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default

    I suppose you did commend the 4 lines starting with __CONFIG in the xxx.inc file inside your PBP directory, right?

    Ioannis

  5. #5
    Join Date
    Sep 2010
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    huh?? do you means 18f2680.inc ? but i dint change anything with it..below is the inc file

    ;************************************************* ***************
    ;* 18F2680.INC *
    ;* *
    ;* By : Leonard Zerman, Jeff Schmoyer *
    ;* Notice : Copyright (c) 2006 microEngineering Labs, Inc. *
    ;* All Rights Reserved *
    ;* Date : 06/05/06 *
    ;* Version : 2.47 *
    ;* Notes : *
    ;************************************************* ***************
    NOLIST
    ifdef PM_USED
    LIST
    "Error: PM does not support this device. Use MPASM."
    NOLIST
    else
    LIST
    LIST p = 18F2680, r = dec, w = -311, w = -230, f = inhx32
    INCLUDE "P18F2680.INC" ; MPASM Header
    __CONFIG _CONFIG1H, _OSC_XT_1H
    __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    __CONFIG _CONFIG3H, _MCLRE_ON_3H & _PBADEN_OFF_3H
    __CONFIG _CONFIG4L, _XINST_OFF_4L & _LVP_OFF_4L
    NOLIST
    endif
    LIST
    EEPROM_START EQU 0F00000h
    BLOCK_SIZE EQU 64

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


    Did you find this post helpful? Yes | No

    Default

    That is awesome, just opened a ton of possibilities with the speed of ASM, and the ease of DT_INTS and N-Bit Math. Thanks Darrel!
    http://www.scalerobotics.com

  7. #7
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Just a quickie, re IOC interrupts....how do I know which one to use? (previously I was using IOC with a 16f690 & used RABC_INT then, but the PIC I'm using now doesn't have a PORT B)

    From DT's site...

    Several new interrupt sources have been added in version 1.00. GPC_INT, IOC_INT, RAC_INT, RABC_INT and the original RBC_INT are all forms of Port Change Interrupts. The chip being programmed determines which one you need to use.

    Where do I look to establish this info?

    I'm using one of the newer 14 pin 16F1823 PICs.

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


    Did you find this post helpful? Yes | No

    Default

    The key is to look in the INTCON register.

    For the 16F690, INTCON.0 is RABIF. So you would use RABC_INT.

    With the 16F1823, INTCON.0 is IOCIF, so it's IOC_INT.

    I could probably make it so IOC_INT works for all of them.
    They are all "Interrupt On Change".
    DT

  9. #9
    Join Date
    May 2012
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    Hello good people,


    I follow this forum for a long time, it is excellent! I found a lot of good stuff on it.


    Now I have a problem with the code from Mr. Darrel Taylor.


    Thus, I use pic18f2550 and connect DS1307z and 4 PWM channels to PORTA


    SDA Var PORTA.1
    SCL Var PORTA.0


    ASM
    SPWM_LIST macro
    SPWM_PIN PORTA, 2, _CH1
    SPWM_PIN PORTA, 3, _CH2
    SPWM_PIN PORTA, 4, _CH3
    SPWM_PIN PORTA, 5, _CH4
    endm
    SPWM_INIT SPWM_LIST


    INT_LIST macro
    INT_Handler TMR1_INT, SPWMhandler, ASM, yes
    endm
    INT_CREATE
    ENDASM
    @ INT_ENABLE TMR1_INT


    Now i got problem with this configuration. When i enable SPWM_LIST then RTC stop working, in fact he working but value he give, its not good. When i disable software pwm, RTC is working good.


    I hope that you understande what is my problem and that one of you has a solution for this problem.


    Sory for my english


    Thanks a lot, Damir

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


    Did you find this post helpful? Yes | No

    Default Re: Instant Interrupts - Revisited

    Do you have this in your program ... ?

    Code:
    ADCON1 = 15
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by reik6149 View Post
    hi all, i face a problem here.

    why when im trying to compile the dt_ints-18 file without changing anything, it shows

    Error[113] c:\picbas~1.47\pbppic18.lib 1170 : symbol not previously defined (int_entry_H)

    im using 18f2680
    It's not really clear, but it sounds like you might be trying to compile the include file, rather than including it in your code. You are supposed to compile something like this:

    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   TMR1_INT,  _ToggleLED1,   PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    T1CON = $31                ; Prescaler = 8, TMR1ON
    @ INT_ENABLE  TMR1_INT     ; enable Timer 1 interrupts
    
    Main:
      PAUSE 1
    GOTO Main
    
    '---[TMR1 - interrupt handler]--------------------------------------------------
    ToggleLED1:
         TOGGLE LED1
    @ INT_RETURN
    Last edited by ScaleRobotics; - 13th September 2010 at 09:21.
    http://www.scalerobotics.com

  12. #12
    Join Date
    Sep 2010
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    yea !! it works !!!! thank you very much ! im too busy body and trying to compile the file each of it.zzzz

  13. #13
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Nothing wrong there.

    There are two different actions that can change the way INT_ENABLE works with version 1.10.

    DEFINE INT_ENABLECLEARFIRST 1 ; (default)
    With the above define, which is also the default, whenever you INT_ENABLE, the flag is automatically cleared before the interrupt is enabled.

    DEFINE INT_ENABLECLEARFIRST 0
    Whith this define, the flag is NOT cleared.
    This can dramatically change the results and cause immediate interrupts if the flag is already set.

    If INT_ENABLECLEARFIRST is 0, then INT_ENABLE takes one instruction cycle.
    If INT_ENABLECLEARFIRST is 1, then INT_ENABLE takes two instruction cycles.

    INT_DISABLE always takes one instruction.

    thanks for the clarification Darrel!

    I look forward to the day where I don't have to read something 10 times ...and still not be 100% sure what it means! Until then please humour me - I'm using V1.1 of your interrupts ...when you mention the default is for your code to clear any interrupt flag (ie prior to enabling) , but then I got confused when seeing this accompanying snippet....

    DEFINE INT_ENABLECLEARFIRST 1 ; (default)

    So, Pop quiz, should I....

    a) should I be putting such a line at the top of my program?
    B) modifying DT_INTS-14.BAS?
    c None of the above (it's erhm..... done by default!)

    thanks!

  14. #14
    Join Date
    Sep 2010
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    finally i could done with the code, hereby special thanks to darrel taylor and scalerobotics !!!

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


    Did you find this post helpful? Yes | No

    Default

    Hey Darrel, I have a question about N-Bit math as it relates to DT_INTS ASM type interrupt.

    Would the ASM part of the N-Bit Math qualify as an assembly interrupt? for instance, can I do math like this in the middle of an asm type interrupt handler, without having to worry? I am not really talking about this code (your degree conversion example) but doing math like this inside an assembly interrupt handler. Or since it is using an include file, I have to worry?

    Code:
       ASM
         MOVE?WP  _degree_Total, _Temp1           ; copy degrees to a PVAR
         MOVE?CP  65535, _Temp2                   ; put multiplier in a PVAR
         MATH_MUL _Temp1, _Temp2, _Temp1          ; Temp1 = DEG * 65535
         MOVE?CP  35999, _Temp2
         MATH_DIV _Temp1, _Temp2, _Temp1          ; Temp1 = Temp1 / 35999 (16-bit result)
         MOVE?PP  _Temp1, _Temp2                  ; copy result to Temp2
         MATH_ROR _Temp2                          ; rotate right 4 times
         MATH_ROR _Temp2
         MATH_ROR _Temp2
         MATH_ROR _Temp2                          ; Temp2 is now 12-bits
         MOVE?PW  _Temp1, _Decimal_value_16bit    ; copy PVAR's to WORDs
         MOVE?PW  _Temp2, _Decimal_value_12bit
       ENDASM
    Thanks,

    Walter
    Last edited by ScaleRobotics; - 13th November 2010 at 21:30.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    > Would the ASM part of the N-Bit Math qualify as an assembly interrupt?
    Absolutely!

    The math routines don't use any of PBP system variables.
    But they do use an FSR, so that must be saved/restored at the beginning/end of the ISR.

    There are two macro's included in N-Bit_Math that do the FSR save/restore ...

    @ FSRSAVE
    ; -- math code here --
    @ FSRREST

    ADD: DT_INTS already saves/restores the FSR's, so if you're using DT_INTS, there's nothing to worry about.

    hth,
    Last edited by Darrel Taylor; - 13th November 2010 at 21:42. Reason: ADDED
    DT

  17. #17
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default

    I downloaded the latest version 1.10 for the DT-INTS14 and now I get a lot of errors.

    Does anyone else has the same problem? With v1.0 had no error (but nothing was working either.... )

    I want to use IOC of a F887 device.

    The test code is this:

    Code:
    DEFINE OSC 4
    
    ;----- Configuration bits ------------------------------------------------
    @Line1 = _DEBUG_OFF & _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_OFF
    @Line2 = _CP_OFF & _MCLRE_ON & _PWRTE_ON & _WDT_ON & _XT_OSC
    
    @ __CONFIG _CONFIG1, Line1 & Line2
    @ __CONFIG _CONFIG2, _WRT_HALF & _BOR40V
    
    OPTION_REG.0=1		'PSA0 PRESCALER SELECT 1:1 TO 1:256
    OPTION_REG.1=1		'PSA1
    OPTION_REG.2=1		'PSA2
    OPTION_REG.3=1		'PRESCALER TO: 1->WDT, 0->TMR0
    OPTION_REG.4=0		'T0SE SOURCE EDGE 1->H TO L, 0->L TO H
    OPTION_REG.5=0		'T0CS 1->FROM RA4, 0->FROM INT. CLOCK
    OPTION_REG.6=0		'INT EDGE SELECT 0->H TO L, 1->L TO H
    OPTION_REG.7=0		'PULL UP 1->DISABLE, 0->ENABLE
    
    adcon0=%01000001    '0 off
    adcon1=$80'6 off (all digitals)
    ansel=$01
    anselh=$00
    
    PORTA=%00000001:PORTB=%00010000:PORTC=%10000001:PORTD=0:PORTE=0
    
    TRISC=$80:TRISD=0:TRISE=0
    
    TRISA = %00000001:TRISB = %00010000
    
    WPUB=%00010000          'Enable weak pull up on PortB.4
    
    while 1
    wend
    
    ASM
    INT_LIST  macro;    IntSource,  Label,      Type,  ResetFlag?
        INT_Handler     RBC_INT,    _IOC2,      PBP,    yes
        endm
        INT_CREATE            ; Creates the interrupt processor
    ENDASM
    
    @   INT_ENABLE  RBC_INT      ; Enable Port B on change
    '-------------   INTERRUPTS SETUP   ---------------------
    
    IOC2:
        if portb.4=1 then
            high portb.0
        else
            low portb.0
        endif
    @ INT_RETURN
    The errors are like ERROR: (" Add:" wsave1 VAR BYTE $A0 SYSTEM, Or change to wsave BYTE $70 SYSTEM)

    or

    ERROR: (Chip has RAM in BANK3, but wsave3 was not found.) etc

    Ioannis
    Last edited by Ioannis; - 15th September 2010 at 18:44.

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


    Did you find this post helpful? Yes | No

    Default

    Everyone seems to do that.....

    What you need to do is contained in the error messages.
    Follow the directions, and they will go away.
    DT

  19. #19
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default

    Sorry I did not fully understood what you mean...

    With the old (version 1.00) there is no problem in compiling with RBC_INT interrupt. With 1.10 I get various errors like the ones posted.

    Of course I made a mistake in interrupt selection. IOC_INT should be used and not RBC_INT.

    With the old version 1.00, after compiling I get

    ERROR: ("INT_Handler" - Interrupt Flag (INTCON,IOCIF ) not found.)

    and

    ERROR: ("INT_ENABLE" - Interrupt Flag (INTCON,IOCIF ) not found.)

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default

    Hey Iannis,

    This may be a dumb question, but are you including the includes? I don't see them in your code.

    if you are getting the wsave, wsave1, wsave2, or wsave3 errors, change the wsave settings in the DT_INTS-14.bas, like it shows you.
    Last edited by ScaleRobotics; - 15th September 2010 at 20:29.
    http://www.scalerobotics.com

  21. #21
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,170


    Did you find this post helpful? Yes | No

    Default

    Hi. Yes I did included them. The sample was stripped down from the obvious.

    Well, the new DT-INTs have changed a little I suppose.

    OK, Darrel pointed what to do. I did uncomment the wsave1,2,3 lines and put on the main program the lines:

    Code:
    wsave   VAR BYTE    $20     SYSTEM      ' location for W if in bank0
    ;wsave   VAR BYTE    $70     SYSTEM      ' alternate save location for W 
                                             ' if using $70, comment wsave1-3
    It seems that it doesn't matter which one I un-comment as it compiles both.

    But with version 1.10 of the DT-INTs I have a new error about the INTCON,IOCIF flag...

    Ioannis

Similar Threads

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

Members who have read this thread : 4

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