Instant Interrupts - Revisited


Closed Thread
Results 1 to 40 of 773

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    I've been trying to use DT_INTS-14 with a 16F877A. I'm getting errors when trying to compile. Code is as follows:
    Code:
    DEFINE    OSC 4
    
    'Define LCD registers and bits
    Define  LCD_DREG        PORTD
    Define  LCD_DBIT        4
    Define  LCD_RSREG       PORTE
    Define  LCD_RSBIT       0
    Define  LCD_EREG        PORTE
    Define  LCD_EBIT        1
    
    'OPTION_REG.6 = 0 
    OPTION_REG.7=0                               'ENABLE PORTB PULLUPS
    ADCON1 = 7                                   
    Low PORTE.2                                  
    Pause 100                                    
    
    'INCLUDE FILES FOR DT INTERRUPTS  
    INCLUDE "DT_INTS-14.bas"
    INCLUDE "ReEnterPBP.bas"
    
    X         VAR  BYTE
    Y         VAR  BYTE
    Z         VAR  BYTE
    COUNTER   VAR  BYTE
    TAG       VAR  BYTE[26]
    
    INIT:
    'INITIALIZE INTERRUPTS
    ASM
    INT_LIST  macro   ;IntSource,Label,Type,ResetFlag?
            INT_Handler  RBC_INT,  _BChange, PBP, yes                  
        endm
        INT_CREATE
    ENDASM
    
    @ INT_ENABLE RBC_INT
    
    START:
    COUNTER=0
    
    MAIN:
    IF COUNTER=>26 THEN
         LCDOUT $FE,1,"COUNTER: ",DEC COUNTER
         LCDOUT $FE,$C0,STR TAG\15
         COUNTER=0
    ENDIF
    GOTO MAIN
    
    BChange:
    COUNTER=COUNTER+1
    IF PORTB.0=0 THEN
         TAG[COUNTER]=0
    ENDIF
    IF PORTB.1=0 THEN
         TAG[COUNTER]=1
    ENDIF
    @ INT_RETURN
    The errors I'm getting are:
    Error [113] c:(path)pbppic14.lib 1181: Symbol not previously defined (wsave)
    Error [101] c:(path)code\lab-x1.asm 194: Error: (wsave variable not found,)
    Error [101] c:(path)code\lab-x1.asm 258: Error: (" Add:" wsave VAR BYTE $70 SYSTEM)
    Error [101] c:(path)code\lab-x1.asm 315: Error: (Chip has RAM in BANK1, but wsave1 was not found.)
    etc
    etc

    Can somebody tell me what's wrong?

    Thanks

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


    Did you find this post helpful? Yes | No

    Default

    Yes, it is asking you to change the include file here:

    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 out wsave1-3
    
    ' --- IF any of these three lines cause an error ?? ---------------------------- 
    '       Comment them out to fix the problem ----
    ' -- It depends on which Chip you are using, as to which variables are needed --
    wsave1  VAR BYTE    $A0     SYSTEM      ' location for W if in bank1
    wsave2  VAR BYTE    $120    SYSTEM      ' location for W if in bank2
    wsave3  VAR BYTE    $1A0    SYSTEM      ' location for W if in bank3
    It needs to be adjusted for a few different chips. Comment out the wsave at $20, and uncomment the wsave at $70, and try commenting out the wsave1-3.
    Last edited by ScaleRobotics; - 3rd September 2010 at 06:11.
    http://www.scalerobotics.com

  3. #3
    Join Date
    Dec 2008
    Location
    Los Angeles, CA
    Posts
    156


    Did you find this post helpful? Yes | No

    Default

    scalerobotics - Thanks very much.
    Last edited by circuitpro; - 3rd September 2010 at 20:28.

  4. #4
    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 17:24.

  5. #5
    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

  6. #6
    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

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,133


    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

  8. #8
    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 08:21.
    http://www.scalerobotics.com

  9. #9
    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!

  10. #10
    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 !!!

  11. #11
    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 20:30.
    http://www.scalerobotics.com

  12. #12
    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 20:42. Reason: ADDED
    DT

  13. #13
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,133


    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 17:44.

  14. #14
    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

  15. #15
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,133


    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

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 : 6

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