Instant Interrupts - Revisited - Page 12


Closed Thread
Page 12 of 20 FirstFirst ... 28910111213141516 ... LastLast
Results 441 to 480 of 773
  1. #441
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Unhappy

    Hi,

    Result is the same with " T-Elapsed_18" ... straight out of the Package ...

    Executing: "C:\Program Files\Microchip\MPLAB IDE\PBP\PBPMPLAB.BAT" -ampasmwin -k# -p18F452 "T_Elapsed-18.bas"
    Executing: "C:\Program Files\Microchip\MPLAB IDE\PBP\PBPW.EXE" -ampasmwin -k# -p18F452 "T_Elapsed-18.bas"
    PICBASIC PRO(TM) Compiler 2.60, (c) 1998, 2009 microEngineering Labs, Inc.
    All Rights Reserved.

    ERROR: Unable to execute mpasmwin.Message[301] C:\PROGRAM FILES\MICROCHIP\MPLAB IDE\PBP\18F452.INC 23 : MESSAGE: ( PENSEZ à INDIQUER la BONNE CONFIGURATION ... )
    Message[301] C:\PROGRAM FILES\MICROCHIP\MPLAB IDE\PBP\18F452.INC 24 : MESSAGE: ( PENSEZ à INDIQUER la BONNE CONFIGURATION ... )
    Error[116] C:\PROGRAM FILES\MICROCHIP\MPLAB IDE\PROJETS\T_ELAPSED-18.ASM 609 : Address label duplicated or different in second pass (Z00022)
    Error[116] C:\PROGRAM FILES\MICROCHIP\MPLAB IDE\PROJETS\T_ELAPSED-18.ASM 672 : Address label duplicated or different in second pass (Z00023)
    Error[116] C:\PROGRAM FILES\MICROCHIP\MPLAB IDE\PROJETS\T_ELAPSED-18.ASM 725 : Address label duplicated or different in second pass (Z00024)
    Error[116] C:\PROGRAM FILES\MICROCHIP\MPLAB IDE\PROJETS\T_ELAPSED-18.ASM 756 : Address label duplicated or different in second pass (Z00025)
    Halting build on first failure as requested.
    BUILD FAILED: Fri Aug 21 12:08:46 2009
    ************************************************** ***********************
    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. #442
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Lightbulb

    Strange thing ...

    DT 14 bits interrupts Examples Compile fine ( With MPLAB ), but NOT 16 bits interrupts Examples ...

    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 " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    No wonder I don't like MPLAB.

    The problem seems to have something to do with the -k# command line option. (new option for pbp2.60)
    If I use the same batch file that MPLAB uses ... PBPMPLAB.BAT
    Then this command gives me the same errors you reported.
    c:\PIC\PBP260\PBPMPLAB.BAT -ampasmwin -k# -p18F452 "Tracteur.bas"
    If I remove the -k# option it compiles fine.

    I haven't found a way to remove it from within MPLAB.
    And I think if you did, you wouldn't be able to debug in MPLAB.

    Added: In the PBP manual it only shows -k- and -k+. -k# doesn't even seem to be a valid option.
    Not that it matters much, because it fails with either -k- or -k+ too.
    Last edited by Darrel Taylor; - 22nd August 2009 at 02:15. Reason: -k+-
    DT

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


    Did you find this post helpful? Yes | No

    Lightbulb Oh ok!

    I see exactly what's happening now.
    This is one for meLabs to solve.

    In an attempt to produce the COFF information for debugging with MPLAB, ... PBP with the -k option places Z????? Labels on every line of code ... including the "ASM" or @ lines.

    If the program has any ASM macros in it (like DT_INTS), you can normally jump in and out of ASM anytime you need to within that macro.

    But with it putting labels at the "ASM" statements, ... when those macros get used (more than once) it duplicates labels that were not in the original program.

    For instance with this macro ...
    Code:
    ASM
    MyMacro  macro
       ; asm statements here
      ENDASM
       ; PBP statements here
      ASM  ; This statement creates a label in the middle of a macro.
      endm
    ENDASM
    
    @ MyMacro  ; The first time it's used is OK
    @ MyMacro  ; the second time or more duplicates that label
    I'll send a report to support at melabs.com
    DT

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


    Did you find this post helpful? Yes | No

    Default

    OMG!

    If it's making a label for every PBP statement.
    Then ANY PBP statements in a macro will cause the same error.

    Apparently, every program I've ever written is now useless.
    Well, (with MPLAB).
    <br>
    DT

  6. #446
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Unhappy

    Quote Originally Posted by Darrel Taylor View Post

    If I remove the -k# option it compiles fine.

    .
    Hi darrel ...

    YES ... but BUILD fails ... no HEX generated, halas.

    Bouhouuuuu ...

    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 " !!!
    *****************************************

  7. #447
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default

    I am still at 2.50c and although I have an itch to upgrade to 2.60 I do no think I'll do it now.

    Darrel, If one uses MCS to edit and complile (with MPASM assembler) is there a problem?

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default

    Am I following this correctly?
    The problem is not with the new PBP it is with the new MPLAB?
    Does it work with the MPLAB that we used with PBP 2.5?
    Dave
    Always wear safety glasses while programming.

  9. #449
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink

    Hi, Dave and Ioannis

    YES ...

    I really think it's URGENT to wait a little !!!

    BUT it seems the problem only Occurs with DT 18 Instant Interrupts ...

    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 " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    So other includes with ASM work properly?
    That would be strange...
    Dave
    Always wear safety glasses while programming.

  11. #451
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default

    Thanks Alain.

    But with MCS does it compile OK?

    Ioannis

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    BUT it seems the problem only Occurs with DT 18 Instant Interrupts ...
    NOT TRUE!

    As explained in the previous posts, the problem will happen with ANY program that uses PBP statements inside of macro's, when using MPLAB<hr>

    Ioannis,
    PBP 2.60 is really nice. And it works really well with Microcode Studio.

    MPLAB is the problem. But trying to make PBP work with the new MPLAB, meLabs made a mistake, and now it causes new problems.

    Don't wait, go ahead and get the upgrade, but forget about MPLAB.
    <br>
    DT

  13. #453
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by Darrel Taylor View Post
    NOT TRUE!

    As explained in the previous posts, the problem will happen with ANY program that uses PBP statements inside of macro's, when using MPLAB<hr>

    <br>
    Hi, Darrel

    You should have understood :

    It works with "DT_INTS-14.bas" ... but not with "DT_INTS-18.bas"

    Its a pity to have also lost the PBP label NAMES ...

    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 " !!!
    *****************************************

  14. #454
    Join Date
    Dec 2005
    Posts
    24


    Did you find this post helpful? Yes | No

    Default

    Darrel,
    Quick question, off topic from the most recent posts. I am using a PIC16F876A part with the DT_INTS-14.bas and using a timer0 interrupt, everything works wonderful, many many thanks! but when my program size goes past the 2k size I get the message when compiling "Message[306] ... Crossing page boundary -- ensure page bits are set." while I know this is only a warning, my program seems to work fine, but I would like to double check, whether this is a concern or not.
    Thanks,
    Terry

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


    Did you find this post helpful? Yes | No

    Default

    Hi Terry,

    DT_INTS won't have any problems when it crosses page boundaries, and most normal PBP programs won't either.

    But if the program uses the BRANCH command or has assembly language routines, it can be a problem.


    Crossing Page Boundary - Solution
    http://www.picbasic.co.uk/forum/showthread.php?t=40

    Warning (and other Compilation Error) Messages (Melanie)
    http://www.picbasic.co.uk/forum/showthread.php?t=555
    DT

  16. #456
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by Ioannis View Post
    Thanks Alain.

    But with MCS does it compile OK?

    Ioannis
    Hi, Ioannis

    I've verified in real life ... my old programs Work fine, compiled With MCS.

    Was not so evident due to little changes in the resulting HEX ...

    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 " !!!
    *****************************************

  17. #457
    Join Date
    Dec 2005
    Posts
    24


    Did you find this post helpful? Yes | No

    Default

    Darrel,
    In my PBP code the only assembly routine would be your code for the interrupt and I have no branch routines. My interrupt routine is in PBP, not assembly, but if is was, could this then be a possible issue. Also in searching this thread, I did see the possibly of inserting "@ errorlevel -306 " to suppress the warning, if this is a OK, where does it makes sense to insert it, such as right after the includes.
    Thanks for your help,
    Terry

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


    Did you find this post helpful? Yes | No

    Default

    The ASM that declares Interrupts, will be OK because all the GOTO's and GOSUB's/CALLs in DT_INTS already use Paging code.

    If the ISR is assembly language, there would be a possibility of page problems.
    But if you use L?GOTO or L?CALL instead of goto or call, then it won't be a problem either.
    They are macro's that are part of PBP and automatically set PCLATH to the correct page before jumping. They also reset to BANK0, so anywhere they jump to should assume the bank is currently 0.

    The -306 line can technically be put anywhere in the program before the first Page Crossing. But it's usually found at the very top, right up there with your __CONFIG lines.
    <br>
    DT

  19. #459
    Join Date
    Dec 2005
    Posts
    24


    Did you find this post helpful? Yes | No

    Default

    Many Thanks Darrel,
    For your help now and for a GREAT easy to use approach for interrupts using PBP.
    Terry

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


    Did you find this post helpful? Yes | No

    Default

    Alain,

    I got ahold of Charles Leo, RE: the duplicate label problem.

    Like I said before, I don't use MPLAB so I didn't know you could do this.

    Under Project | Build Options | Project | PICBASIC PRO tab ...
    Check the "Use Alternate Settings" checkbox, and remove the -k- or -k# parameter.

    The Tracteur program then compiles without error within MPLAB.
    And the setting only affects the Tracteur program.



    HTH,
    DT

  21. #461


    Did you find this post helpful? Yes | No

    Default RBC_INT Question

    I am running into a problem trying to figure out how to use RBC_INT on portB.1

    I am using a 16F883 and I am looking for B.1 to drop from high to low. Below is part of my code to read the interrupt.

    readchar:
    @ INT_DISABLE RBC_INT
    Dummy = PortB
    if Dummy.1 = 0 then
    goto good_int
    Else
    @ INT_CLEAR RBC_INT
    @ INT_ENABLE RBC_INT
    @ INT_RETURN
    endif
    good_int:
    ' process the interrupt code here


    I know this is not correct but I cannot figure out why?

    Any help would be appreciated.

  22. #462
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Wink

    Quote Originally Posted by Darrel Taylor View Post
    Alain,

    I got ahold of Charles Leo, RE: the duplicate label problem.

    Like I said before, I don't use MPLAB so I didn't know you could do this.

    Under Project | Build Options | Project | PICBASIC PRO tab ...
    Check the "Use Alternate Settings" checkbox, and remove the -k- or -k# parameter.

    The Tracteur program then compiles without error within MPLAB.
    And the setting only affects the Tracteur program.

    HTH,
    Hi, Darrel

    Thanks for the trick ...

    Now, we've completely lost the debug view of produced ASM ... no more labels and even breakpoints can't be used.

    Hope Melabs will correct that soon ... !!!

    BTW I've appreciated Melabs has cleaned the LOOKUP tables ... New EEPROM commands are also fine ... knowing the LSByte is written first !!!

    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 " !!!
    *****************************************

  23. #463
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Disturbance in the force

    Hi everyone,
    I think I'm getting very close to understanding DT's interrupt routine but need some direction.
    I'm using a PIC16F688 to make myself a test fixture to test some product but pretty sure I did something wrong in the setups.
    Using this small test program and a scope to monitor an output, I see the "Toggling" led stop during the interrupt routine. This only happens when PAUSE, FOR/NEXT and PAUSEUS is used in the main.
    Ultimately, I will need to send serial data using SEROUT2 continueously in the background so I can do other chores in the foreground that will use TMR1, A/D and some simple LED indications.

    Code:
    '*************************************************************************
    '*  Name    : Test fixture.BAS                                 
    '*  Author  : Louis Chagoya                                     
    '*  Notice  : Copyright (c) 2008 Link M Technologies            
    '*          : All Rights Reserved                               
    '*  Date    : 8/24/2009                                       
    '*  Version : 1.1                                         
    '*  Notes   : This system uses the PIC16F688 to learn DT's Interrupt system
    '*  while utilizing other signalling functions at the same time.
    '*************************************************************************
    '/////////////////////////////////////////////////////////////////////////
    '                       Configs
    '/////////////////////////////////////////////////////////////////////////
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
    OSCCON = %01100001      ' Oscillator set to 4MHz, bits 6-4
    CMCON0 = 7		        ' Analog comparators off
    ADCON0 = %10010000      ' A/D right justified, Vref=VDD, AN2 selected
    ADCON1 = %01010000      ' A/D conversion CLK/16
    ANSEL = %00000100       ' AN2 set to analog input rest digital
    TRISA = %00101101       ' Set ports 0,2,3 and 5 as inputs, rest outputs
    TRISC = %00000000       ' Set all pins as outputs
    
    'DEFINE OSC 8           ' Define OSC to 8Mhz for PAUSE setting
    DEFINE ADC_BITS 10     ' ADCIN resolution  (Bits)
    DEFINE ADC_CLOCK 5     ' ADC clock source  (Fosc/16)
    DEFINE ADC_SAMPLEUS 7  ' ADC sampling time (uSec)
    DEFINE SER2_BITS 8     ' Set up baud rate for 7812bps
    
    '/////////////////////////////////////////////////////////////////////////
    '                        Pin I/O naming
    '/////////////////////////////////////////////////////////////////////////
    Data_In VAR PORTA.0     ' Pin 13 Data from UUT
    Data_Out VAR PORTA.1    ' Pin 12 Data to UUT
    '        VAR PORTA.2    ' Pin 11 GPS input from UUT
    Test VAR PORTA.3        ' Pin 4 Push button to begin test
    Bypass VAR PORTA.4      ' Pin 3 Puts UUT into Bypass or Active mode
    Byp_Sel VAR PORTA.5     ' Pin 2 Select type switch input
    BCDval var PORTC        ' All of PortC declared as variable
    Ready VAR PORTC.0       ' Pin 10 READY LED
    Byp_Pass VAR PORTC.1    ' PIn 9 BYPASS test PASS LED - Green
    Byp_Fail VAR PORTC.2    ' PIn 8 BYPASS test FAIL LED - Red
    Act_Pass VAR PORTC.3    ' PIn 7 ACTIVE test PASS LED - Green
    Act_Fail VAR PORTC.4    ' PIn 6 ACTIVE test FAIL LED - Red
    Pwr_ON VAR PORTC.5      ' PIn 5 Provides power to UUT
    
    
    '/////////////////////////////////////////////////////////////////////////
    '                        Variable declarations
    '/////////////////////////////////////////////////////////////////////////  
    i VAR BYTE              ' Increment counter when needed
    cksm VAR BYTE           ' Checksum variable
    
    
    '/////////////////////////////////////////////////////////////////////////
    '                       DT's Interrupt Routine
    '/////////////////////////////////////////////////////////////////////////
    INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
    
    ASM
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR0_INT,    _Gen_Data,   PBP,  YES
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    '.....Various OPT_Reg tries....
    
    'OPTION_REG.3 = 1             ' Prescaler is assigned to the WDT
    'OPTION_REG.2 = 1             ' N/G, even with WDT ON
    'OPTION_REG.1 = 1
    'OPTION_REG.0 = 1             ; REGISTER 5-1: Prescaler = 1:1 via WDT rate
    
    OPTION_REG = 7               ' Times out in 65.2ms. Will need 100ms when
                                 ' get it to work
    @ INT_ENABLE  TMR0_INT       ; enable Timer 0 interrupts
    
    cksm = 85
    
    '/////////////////////////////////////////////////////////////////////////
    '                           Main Program
    '/////////////////////////////////////////////////////////////////////////
    start:     
         
         TOGGLE act_fail    ' Use this output to monitor routine
         PAUSE 1
         TOGGLE act_fail
         PAUSE 1
           
    GOTO start
    
    '---[TMR0 - interrupt handler]--------------------------------------------
    
    Gen_Data:
    
        SEROUT2 Data_out, 108, [cksm]   ' Serial out cksm value at 7812bps
        PAUSEUS 3720                    ' Total time= 5ms
    
    @ INT_RETURN
    
    
    END
    My understanding is that main program should not be disturbed by the interrupt routine if done properly. In this case, I'm hoping I'm not being proper rather than using the wrong PIC for my app.

    Thank for your help...
    Louie

  24. #464


    Did you find this post helpful? Yes | No

    Default 16f688

    Louie,

    There are a couple of things I found while using Instant Ints. that may be worth looking at.
    I am not an expert on them, I have found out what works for me by trial and error, and error and error as with all things Pic. But when you find the solution they work great!

    When entering the interrupt, I stop additional interrupts from being serviced or re-serviced until I am ready to release control again.

    INTCON needs to be set, looking at bits 7,6,5 and 2 page 15 and 45-47 of the data sheet.

    Code:
    INTCON = %111xx1xx      ' with x set for other functions and the 1's are a guess for your application
    Code suggestion
    Code:
    '---[TMR0 - interrupt handler]--------------------------------------------
    
    Gen_Data:
    @ INT_DISABLE TMR0_INT
        SEROUT2 Data_out, 108, [cksm]   ' Serial out cksm value at 7812bps
        PAUSEUS 3720                    ' Total time= 5ms
    
    @ INT_CLEAR TMR0_INT
    @ INT_ENABLE TMR0_INT
    @ INT_RETURN
    
    
    END
    Kevin

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


    Did you find this post helpful? Yes | No

    Default

    Kevin,

    You should NOT set INTCON, PIEx, PIRx, IPRx or any other interrupt related registers manually. DT_INTS handles all of those bits for you.

    There is NO reason to INT_DISABLE / INT_ENABLE inside of an interrupt handler. Interrupts are automatically disabled by the hardware during an interrupt event, and can not cause another interrupt until the current one is finished. You are confusing things with ON INTERRUPT which must have DISABLE/ENABLE wrapped around them.

    Louie,

    When an interrupt occurs, the main program STOPS.
    Program execution jumps to the ISR where it remains until the handlers have completed.
    The main program will continue only after the entire ISR is finished.

    The ISR and the main program do not execute at the same time.

    It's why they're called Interrupts.
    They Interrupt the main program to go do something else.
    <br>
    DT

  26. #466


    Did you find this post helpful? Yes | No

    Default

    Darrel,

    Thanks! I will modify my code, this will reduce overhead. Like I tried to say I do not know much about this, just enought to be dangerous and wrong most of the time.

    I have been using the 16F688 and the 16F883 on a couple of projects, your routines work great.

    When wanting to use the RBC_INT I found I had to set IOCB to get the interrupt to work on one input of PORTB.


    Thanks,
    Kevin

    ____________________

    If you want the best seat in the house, you will have to move the Cat.

  27. #467
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default

    Thanks for ending the misery Darrel.
    I guess I was seeing too much into it. I still need to learn to juggle the events properly so they don't clash.
    When I read the second post that says "Well, for one, this Blinky Light program will continue Blinking at the same rate, no matter what else you add to the Main: program loop. Try doing that with pauses.", it's true, but I made the mistake of assumming that the main program would go along like some absent minded fool without a bother in the world.


    Thanks for all your contributions,
    Louie

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by hatchethand1000 View Post
    I have been using the 16F688 and the 16F883 on a couple of projects, your routines work great.
    Sweet!

    When wanting to use the RBC_INT I found I had to set IOCB to get the interrupt to work on one input of PORTB.
    Yes, you're correct.
    I shouldn't have said "... or any other interrupt related registers manually". That was a little too broad.
    There are several registers like IOCB that will need to be changed.

    I probably should have limited it to ... "You should NOT set INTCON, PIEx, PIRx, IPRx". As those are the only interrupt bits that DT_INTS does handle for you.

    Thanks for the correction.

    If you want the best seat in the house, you will have to move the Cat.
    Which is why the "best" seats in my house "belong" to the cats.
    They know not to sit in mine ... they might get sat on.
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by LinkMTech View Post
    Thanks for ending the misery Darrel.
    I guess I was seeing too much into it.
    Well don't end it there ...
    It's probably that you're "not seeing enough into it".

    Interrupts can definitely be used to make multiple things happen at the same time.
    It's just that those things need to be happening in hardware.

    If you want to send RS232 from an interrupt, then you should use the USART.
    If you want to have an interrupt driven PAUSE, then use a Timer.

    Jumping to the ISR and executing a software routine like serout(2) is not normally very productive, because the same routine could have been run from the main program without interrupts without much additional overhead. And since either way ... the program can't continue until the serout has completed, with or without interrupts makes little difference.

    But if that interrupt uses the hardware USART, only a few instructions need to be executed to start the USART sending data, then it immediately returns from the interrupt and continues running the main program at the same time that the USART is sending the data.

    There are several hardware peripherals on the various PIC's, and you might have 5 or 6 things all happening at the same time.

    While software timed, bit-bang routines in your interrupts will occasionally be very useful ... avoid them at all cost.

    Hardware and Interrupts make good companions.

    hth,
    DT

  30. #470
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default

    Well don't end it there ...
    Alrighty then! Just when I was about to go with plan "B", add a PIC12F683 as a stand alone serial generator.
    I just took a look at USART along with Mister E's PIC calculator and found that 7812 baud is configurable. A first glance some time ago gave me the impression that only common baud rates were available. I just recently discovered SEROUT2!
    Is the USART hardware like the HPWM that can run continueously in the background?
    If so, which commands will disrupt it or vice versa? I ran into some surprises when trying to use the HPWM while using the A/D in a WHILE:WEND. So went with PWM sprinkled through out the program along with a nice filter to hold my Vout.

    The RS232 does not have to be interrupt started, just running all the time with the same 8x8 bytes of data. It will be processed and returned without any delay so I will have to act on it immediately.
    Do you think this is still possible? Or go with plan "B"?
    Louie

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


    Did you find this post helpful? Yes | No

    Default

    7812 baud ... ECU / ALDL ??

    Yes, the USART will continue sending data at the same time the main program is running. But you have to feed it bytes every now and then.

    The TX_INT (USART Transmit Interrupt) makes it fairly easy.
    When the transmit buffer is empty it generates a TX_INT, which jumps to a handler that sends the next byte.

    That handler just needs to send one byte at a time, by keeping track of where it is in an array and incrementing/wrapping as needed. It only takes a few instructions for each byte, so the main program is hardly affected by it.

    You can then very easily have it sending continuous RS232 data via the USART, while the main program continues what it's doing at the same time.

    Typically, when you have data to send, you ENABLE TX_INT's, and when it's finished sending the available data, DISABLE TX_INT. And that handler won't be called again until there's more data.

    I ran into some surprises when trying to use the HPWM while using the A/D in a WHILE:WEND. So went with PWM sprinkled through out the program along with a nice filter to hold my Vout.
    The HPWM command doesn't like being updated continuously.
    It resets the PWM cycles every time it executes.

    If you limit the HPWM updates to only when the Duty value changes, it gives a better response.
    You can also synchronise the updates with Timer2 to make it "glitch-free".

    hth,
    DT

  32. #472
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default

    Thanks for the direction Darrel. I did some research on the USART and like what I found now that I'm beginning to understand the use of your interrupt routine and how the information is presented in the data sheets. I think it makes more sense as the need increases.

    7812 baud ... ECU / ALDL ??
    The 7812 baud is on a motorcycle ECM alias ECU.

    The HPWM command doesn't like being updated continuously.
    It resets the PWM cycles every time it executes.

    If you limit the HPWM updates to only when the Duty value changes, it gives a better response.
    You can also synchronise the updates with Timer2 to make it "glitch-free".
    Sorry, I wasn't clear on my attempt with the HPWM. I set it early in the program to run on its own and would get updated only when needed (when a rider shifts gear). But while using a 55ms timer controlled ADCIN inside a WHILE:WEND, I found it jumping out of the loop way before the timer overflowed because the HPWM triggered it somehow. So I'm sure I didn't account for other hardware commonalities.
    Louie

  33. #473


    Did you find this post helpful? Yes | No

    Unhappy

    I've been wondering what it would take...or if anyone has managed to change the Timereload (External Constant), to a variable that can be altered in the main program...
    Actually, I would like to load this value from eeprom on startup, but I am at a loss for how to go about this short of learning asm...


    ;---Reload Timer1------ (T1 asm interrupt handler)
    ASM
    ReloadTMR1
    MOVE?CT 0, T1CON, TMR1ON ; 1 stop timer
    MOVLW LOW(TimerReload) ; 1 Add TimerReload to the
    ADDWF TMR1L,F ; 1 value in Timer1
    BTFSC STATUS,C ; 1/2
    INCF TMR1H,F ; 1
    MOVLW HIGH(TimerReload) ; 1
    ADDWF TMR1H,F ; 1
    MOVE?CT 1, T1CON, TMR1ON ; 1 start timer
    INT_RETURN
    ENDASM

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Michael Wakileh View Post
    I've been wondering what it would take...or if anyone has managed to change the Timereload (External Constant), to a variable that can be altered in the main program...
    Actually, I would like to load this value from eeprom on startup, but I am at a loss for how to go about this short of learning asm...


    Code:
    ;---Reload Timer1------   (T1 asm interrupt handler)
    ASM
    ReloadTMR1
        MOVE?CT  0, T1CON, TMR1ON     ;  1     stop timer
        MOVLW    LOW(TimerReload)     ;  1     Add TimerReload to the 
        ADDWF    TMR1L,F              ;  1     value in Timer1
        BTFSC    STATUS,C             ;  1/2
        INCF     TMR1H,F              ;  1
        MOVLW    HIGH(TimerReload)    ;  1
        ADDWF    TMR1H,F              ;  1
        MOVE?CT  1, T1CON, TMR1ON     ;  1     start timer
      INT_RETURN
    ENDASM
    I'm sure there are a number of ways to do it, but a direct translation of that routine might look like this ...
    Code:
    TimerReload VAR WORD BANK0
    
    ASM
    ReloadTMR1
        MOVE?CT  0, T1CON, TMR1ON     ;  1     stop timer
        MOVF     _TimerReload,w       ;  1     Add TimerReload to the 
        ADDWF    TMR1L,F              ;  1     value in Timer1
        BTFSC    STATUS,C             ;  1/2
        INCF     TMR1H,F              ;  1
        MOVF     _TimerReload + 1,w   ;  1
        ADDWF    TMR1H,F              ;  1
        MOVE?CT  1, T1CON, TMR1ON     ;  1     start timer
      INT_RETURN
    ENDASM
    Then TimerReload is a PBP word variable.
    You can calculate it or read it from EEPROM as desired.
    DT

  35. #475


    Did you find this post helpful? Yes | No

    Smile IOC handler

    Thanks Darrel! works great!


    I've been experimenting with the interrupt system lately and although its not relevant for my purposes, I noticed something I can't explain...
    I'm guessing it has something to do with the port variables saved...

    I have a pic12f683
    Led1 GPIO.1 toggled by 1Hz Timer1 interrupt (...in my case via external crystal)
    Led2 GPIO.2 toggled by IOC/RB interrupt.
    The RB interrupt also starts or stops the timer...allowing for control of the blinking LED1. This part works however LED2 only turns off briefly when the button is pressed.

    Things work normal if a flag bit is "toggled" and the Leds are controlled in the main program...

    Code:
    RBPortIntPBP:
    'toggle gpio.2
    if T1CON.0 = 0 then
    TOGGLEFLAG = 1              'attempt doing this via main handler
    else
    TOGGLEFLAG = 0
    endif
    pause 300
    @ INT_RETURN


    Can anyone explain, and is there away to do this from within the handler?

  36. #476
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default

    Hi. I am getting an error Symbol not previously defined (PIR2) on a 16F628 with Darrels interrupts.

    On the program I do not use any PIR2 register. So why does this error come up? Can't this be taken care automatically?

    Also if I want to disable TMR0 interrupts inside the timer0 INT Handler, will the Interrupts be enabled on exiting the routine? Like this:

    Code:
    INT_Service_TMR0:
    @ INT_DISABLE TMR0_INT
        tmr0=21                 'Preload for 60msec time out
        timer0=1                'timer 0 has timed out flag
    @ INT_RETURN    <<<<<<<<----------------Here I do not want to enable timer0
    Thanks,
    Ioannis
    Attached Files Attached Files
    Last edited by Ioannis; - 4th October 2009 at 21:49.

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


    Did you find this post helpful? Yes | No

    Default

    Michael,

    With the Port Change Interrupts ...
    The PORT (GPIO) has to be read within the handler to end the mismatch condition. Otherwise it can't clear the interrupt flag and as soon as it exits the ISR it'll jump right back into another interrupt, essentially halting the main program.

    You'll also receive interrupts on both the Rising and Falling edges, so you'll need to check the state of the PIN to know if it's been pressed or released.

    And since you have to read the PORT to know which state the PIN is in, that qualifies as the port READ, and ends the mismatch.

    Code:
    RBPortIntPBP:
        if GPIO.3 = 0 then  TOGGLE GPIO.2
        pause 10
    @ INT_RETURN
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ioannis View Post
    Hi. I am getting an error Symbol not previously defined (PIR2) on a 16F628 with Darrels interrupts.
    Ioannis,

    I've compiled your program here for a 16F628 with several versions of PBP, and I don't get that error.

    <strike>Have you made any changes to the DT_INTS-14 file?</strike>

    Added:
    Oh shoot, now I remember.
    That was fixed in version 0.93 (Jan '06)

    Try downloading the lastest version.
    http://www.darreltaylor.com/DT_INTS-14/downloads.htm
    <br>
    Last edited by Darrel Taylor; - 4th October 2009 at 22:45. Reason: Added
    DT

  39. #479
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default

    Hi Darrel.

    Yes I commended the wsave3 as I compile for 16F628 chip.

    Also to get rid of the error I commended out the PIR2 references too.

    I attach the modified file to check.

    Thanks,
    Ioannis
    Last edited by Darrel Taylor; - 4th October 2009 at 23:06. Reason: deleted file to minimize confusion

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


    Did you find this post helpful? Yes | No

    Default

    Sorry, I added to my previous post.
    Didn't get it in there soon enough.

    It should help.
    <br>
    DT

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

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