Instant Interrupts - Revisited


Closed Thread
Results 1 to 40 of 773

Hybrid View

  1. #1
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Hi, Ioannis

    Compiles fine adding ...

    Code:
    @ __CONFIG  _LVP_OFF & _BODEN_ON & _CP_ALL & _MCLR_OFF & _PWRTE_ON & _WDT_ON & _INTRC_IO
    to the top of your code ...

    and

    Code:
    '*****************************************************************************
    'Includes
    '*****************************************************************************
    
    INCLUDE "DT_INTS-14.bas"
    INCLUDE "ReEnterPBP.bas"
    
    '-------------   INTERRUPTS SETUP   ---------------------
    ASM
    INT_LIST  macro;    IntSource,  Label,      Type,  ResetFlag?
        INT_Handler     TMR1_INT,   _timer,     PBP,    yes
        INT_Handler     RBC_INT,    _in_triger, PBP,    yes
        endm
        INT_CREATE            ; Creates the interrupt processor
    ENDASM
    just BEFORE the Interrupts setup ... ( why ??? good question !!!)

    It DIDN'T Compile placed at the top of program ... that's it

    - also think to uncomment Wsave, Wsave1 .... etc. in DT INTs listing ....



    Alain
    Last edited by Acetronics2; - 20th April 2010 at 16:57.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    Alain, there is no problem here where the lines of includes are placed. Either on the very top or just before the macros... Are you sure about that?

    Ioannis
    Last edited by Acetronics2; - 20th April 2010 at 19:55.

  3. #3
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by Ioannis View Post
    Alain, there is no problem here where the lines of includes are placed. Either on the very top or just before the macros... Are you sure about that?

    Ioannis
    Hi,

    Yess .. I'm pretty sure !!!

    I had an error raising ( Vars_Saved not defined ... but it was correctly defined in the listing ) .

    but now I've also uncommented Wsaves and compiler has compiled fine once ... no more compiler errors appears, whatever line the "includes" are placed ...

    a bit strange, but not the first strange thing I see with MCS ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    Have tried to compile from command line and it went OK?

    Ioannis

  5. #5


    Did you find this post helpful? Yes | No

    Default

    I'm looking at a possible necessity to need to upgrade to PIC24's and above...
    I use DT INST INT's with my PIC16's and PIC18's however it would be a royal pain to have to write my own interrupt system for PIC24's and above...

    Is their any work being done on DT Ints at the moment?
    Is their any plans for DT Int's?
    Anyone working on DT int's in a team?

    Thanks

  6. #6
    Join Date
    Feb 2003
    Location
    Sydney, Australia
    Posts
    126


    Did you find this post helpful? Yes | No

    Default

    I have done a lot of work on the PIC24F series using MikroElektronika dsPIC Basic compiler, and have had no issues with Interrupt or having to implement a DT_INT style system. Interrupts are handed well in the compiler, which I think is due to the way the improved architecture handles them. One you try the Peripheral Pin mapping in the 24 series its hard to go back !

    The only issue I had was changing my coding style after years of working with PBP ! I still use PBP for all my 16F and 18F stuff, so don't shoot me down for promoting other peoples products !

    Bill.

  7. #7
    Join Date
    Jun 2005
    Location
    West Australia
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Help with disabling DT_ Int's during a For/Next loop.

    Hi Folks,

    I don't have a lot of experience with using DT's Int's (thank you Darrel!) and had no problems until recently needing to selectively Disable them...

    I have an application measuring wind which requires a rolling (3 x 1 second) update easily taken care of by a For Next loop. At any time a master logger can interrogate this separate wind acquisition unit and request the processed data, but I want the ISR to only occur at the end of the loop so the math can complete as a set.

    The abbreviated code below shows what I am using but I have no Int's when the @ INT_DISABLE INT_INT is inserted. With this removed I do have them but immediately following the Debug data sent from within the ISR the remaining T loop count completes before Clearing and restarting i.e math is performed and data is sent from an incomplete routine.

    Code:
    16F88, PBP 2.60, MPASM 5.20
    
            Include "MODEDEFS.BAS"      ' Include Shiftin/out modes
            Include "DT_INTS-14.bas"    ' Darrel's routines.
            Include "ReEnterPBP.bas"    ' Only needed if Pbp Interrupts used.
    
        Define LCD_DREG PORTB           ' Port for LCD Data.
    	Define LCD_DBIT 4               ' Use upper 4 bits of Port.
    	Define LCD_RSREG PORTA          ' Port for RegisterSelect (RS) bit.
    	Define LCD_RSBIT 7              ' Port Pin for RS bit.
    	Define LCD_EREG PORTA           ' Port for Enable (E) bit.
    	Define LCD_EBIT 6               ' Port Pin for E bit.
    	Define LCD_BITS 4               ' Using 4-bit bus.
    	Define LCD_LINES 2              ' Using 2 line Display.
    	Define LCD_COMMANDUS 2000       ' Command Delay (uS).
    	Define LCD_DATAUS 50            ' Data Delay (uS).
    
        DEFINE DEBUG_REG PORTB          ' Debug pin port
        DEFINE DEBUG_BIT 1              ' Debug pin bit
        DEFINE DEBUG_BAUD 9600          ' Debug baud rate 
        DEFINE DEBUG_MODE 1             ' Debug mode: 0 = True, 1 = Inverted 
    
        DEFINE ADC_BITS 10              ' Set number of bits in result
        DEFINE ADC_CLOCK 3              ' Set clock source (rc = 3)
        DEFINE ADC_SAMPLEUS 50          ' Set sampling time in microseconds 
    
    '    DEFINE OSC 8                    ' Needed if oscon set for 8Mhz.
    '    OSCCON = %01110010              ' 8Mhz (F88).
    
            OPTION_REG.6=0      ' 0=Falling-Edge Trigger.
            OSCCON = %01100010  ' 4Mhz (F88).
            TRISA = %00101111   ' A.5 Set, A.3 WD2, A.2 WS2, A.1 WD1, A.0 WS1.
            TRISB = %00001101   ' B.3 -, B.2 +, B.0 Sin.
            ANSEL = %00001010   ' PORTA.1,3 analog, remainder digital (F88).
            ADCON0 = %11001101  ' Set A/D to Frc, Channel 1, On (F88).                   
            ADCON1 = %10000000  ' R justify (where the 6 MSB of ADRESH read as 0 i.e. 10 bit), Vdd for Vref.
            CMCON = 7         	' Comparators off.
            pause 100           ' Let everything settle...
            RedLED = 0		    ' Red LED Off.
    clear
            debug 10,13,"I'm Alive!",10,13            '
    
    ASM
    INT_LIST    macro      ; IntSource,   Label,  Type,  ResetFlag?
                INT_Handler    INT_INT,  _MyInt,   PBP,  yes
                endm
    INT_CREATE             ; Creates the interrupt processor
    ENDASM
    '@   INT_ENABLE   INT_INT     ; enable external (INT) interrupts     (enabled further down).
    
            GOTO Satu           ' Jump over the subroutines area.
     
    ' Subroutines here in the first page...
    
    ' Program area...
    Satu:      ' Operation when system first powered up.
    
    Running:    ' Normal running routine.
        if x=1 then                     ' Returning from 1Min Rollover or Interrupt.
        gosub ResetAll                  ' Start fresh count - Clear and reset all.
        gosub Read_offsets              ' Retrieve stored values.
        endif                           '
    
    @ INT_DISABLE INT_INT               ; No Ints during the For/Next loop - ensures complete set for math.
        for T = 0 to 2                  ' 3 event sliding window.
        gosub Blinky                    ' LED shows sampling.
        gosub Get_revs                  ' Run the count routine.
        ch = 1                          ' Second channel for direction 1 (ch0 for S1).    
        gosub Get_Dirn                  ' Read the realtime direction.
        LCDOUT $FE,$CF,Dec T            ' Second line, last position - indicates present count.
    
    ' This section averages the speed of the latest three samples i.e. derives Gust. 
    ' This section deals with Wind Direction.
    ' Get instant Wind Direction value.
    ' Update Max and Min Direction
    ' Update Sigma Theta                                       
    ' 1min period report.
        if Wsmpls=60 then               '
        debug 10,10,13,"S1i ",#S1i,", S1x ",#S1x,", Gu1x ",#Gu1x,", Gu1av ",#Gu1av,13,10,_
        "AD ",#AD_res,", WD1av ",#WD1d,", Max ",#D1x,", Min ",#D1n,", ST1av ",#ST1av,10,10,13 ' ****
    x=1    
    goto Running                   ' Reset all and start again.
        endif
        
    Continue:
        pause z                         ' This plus sensor 1 count period should equal 1 second 
        next                            '  Back to loop testing.
    @   INT_ENABLE   INT_INT     ; enable external (INT) interrupts only after For/Next loop is completed.   
        goto Running                    ' Repeat the whole cycle.
      
    '---[INT - interrupt handler]---------------------------------------------------
    MyInt:
    	toggle RedLED                   ' Blink the LED on interrupt.
    ' Report the Av wind speed, Maximum Gust, Maximum Speed, Av dirn and Sigma Theta since last interrupt.
        debug 10,13,dec3 S1av,".",dec1 S1avr,",",dec3 Gu1x,",",dec3 S1x,",",dec3 WD1d,",",dec3 ST1,13,10
        LCDOUT $FE,$C0,"Data out, Reset!"   ' Second line.
        pause 1000                      ' Time enough to read.
        x=1                             ' Flag the interrupt.
    @ INT_RETURN                        ; Return to point of Interrupt and resume.
    Can anyone offer some advice or point out where I am going wrong please?

    Thanks and regards to all,
    Bill
    Last edited by wjsmarine; - 7th May 2010 at 18:54. Reason: code box

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


    Did you find this post helpful? Yes | No

    Default

    Are you still compiling for a 16f887? Because that chip doesn't even have a IOCIF. I think only the 16f1827's and such have one of those. So that is pretty weird.
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    I used DT-INTS 1.10 on a 16f887
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    When compiling the attached file I get the attached error.

    It drives me crazy....

    Ioannis
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by Ioannis; - 15th September 2010 at 20:41.

  11. #11
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Hi Ioannis, you cannot use the wsave variable outside the DT interrupt since such a variable is in use within the routine.

    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
    clear
    INCLUDE "c:\projects\picdem2\DT_INTS-14.bas"
    INCLUDE "c:\projects\picdem2\ReEnterPBP.bas"
    You have to comment/uncomment the variable within DT int routine.

    Al.
    All progress began with an idea

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


    Did you find this post helpful? Yes | No

    Default

    Your code compiles here without errors. PBP 2.60A
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    DT-INTS version 1.00 or 1.10?

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scalerobotics View Post
    Your code compiles here without errors. PBP 2.60A
    To be clearer, your code in post 609 compiles using the code shown. I had not tried it with the IOC_INT, only with the code listed in post 609. I guess you meant that when you changed it to IOC, you got the errors.....

    Sorry

    Walter
    http://www.scalerobotics.com

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


    Did you find this post helpful? Yes | No

    Default

    Thanks all for the support.

    Al.: We are testing the new DT-INTs version 1.10. Here as Darrel pointed out the wsave are set in the main program.

    Darrel: You are correct in the Port change Interrupts. Ok, I have them corrected and the two errors went away. But no joy on Interrupts. It seems that they are never triggered.

    The latest test code is this:

    Code:
    DEFINE OSC 4
    
    @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=%01000000    '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
    
    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
    clear
    INCLUDE "c:\projects\picdem2\DT_INTS-14.bas"
    INCLUDE "c:\projects\picdem2\ReEnterPBP.bas"
    
    '-------------   VARIABLES   ---------------------
    
    code_in             var portb.4
    
    '-------------   VARIABLES   ----------------------
    
    t1con=%00000000         '65,535ms interrupt time base
    
    clear
    goto main
    
    '-------------   INTERRUPTS SETUP   ---------------------
    
    IOCB=%00010000          'Enable IOC on PortB.4
    WPUB=%00010000          'Enable weak pull up on PortB.4
    
    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 code_in then
            high portb.0
        else
            low portb.0
        endif
    @ INT_RETURN
    
    
    main:
    while 1
    toggle portb.2
    pause 100
    wend
    
    End
    Ioannis

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


    Did you find this post helpful? Yes | No

    Default

    Ioannis,

    Remove the second CLEAR statement, and move the GOTO Main after the interrupt declaration, just before the IOC2: handler.

    The interrupt declaration and the IOCB/WPUB must be allowed to execute.
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel.

    Well, with 3 toddlers running around till 10.30 pm sure I will have double CLEAR commands to clear my mind!

    OK I moved the IOCB/WPUB before GOTO main but still no Interrupts occur.

    In fact is second or third try with different controller that I cannot make an interrupt on change to work... Not lucky I guess.

    The latest test code is this:

    Code:
    t1con=%00000000         '65,535ms interrupt time base
    IOCB=%00010000          'Enable IOC on PortB.4
    WPUB=%00010000          'Enable weak pull up on PortB.4
    
    goto main
    
    '-------------   INTERRUPTS SETUP   ---------------------
    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:
        high portb.1
        if portb.4 then
            high portb.0
        else
            low portb.0
        endif
    @ INT_RETURN
    
    
    main:
    while 1
        toggle portb.2
        pause 1000
    wend
    Thanks for the efforts.

    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