Instant Interrupts - Revisited - Page 14


Closed Thread
Page 14 of 20 FirstFirst ... 4101112131415161718 ... LastLast
Results 521 to 560 of 773
  1. #521
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default

    I like smiling faces!

    Amazing! Thanks.

    I have to test them on the new PICs. Wonder whenthey are coming...

    Ioannis

  2. #522
    Join Date
    Jun 2005
    Posts
    20


    Did you find this post helpful? Yes | No

    Default Trying to reach Darrel...

    Hey Darrel--

    I've been trying to reach you re: the consulting I'd hired you to do. I've sent three emails with no response. If you need more money, I'm happy to pay it, and you also have $2200 of my company's equipment... won't you please reply to me?

    Thanks--

    --Alan McFarland
    www.nila.tv

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


    Did you find this post helpful? Yes | No

    Default

    That's just wrong, on so many levels.
    I have no Public response. But I will leave this post here.
    <br>
    DT

  4. #524
    Join Date
    Jan 2010
    Posts
    2


    Did you find this post helpful? Yes | No

    Smile Interrupt timer1 PIC16F628A definitions

    Hi,
    I want to start my home project to control ventilation fan by time period ON and time period OFF and to use LCD out for interface.
    I have just started to write a code in Micro Code studio Plus v.3.0.0.5 with compiler PICBasic PRO v2.50C.

    I made a starting (main) interrupt code as a basis for rest algorithm later. It is based on some desired info I have looked on the internet pages. Seems to be workable and started to compile this code. When compiling I have got some results like assembler errors as following:
    Error xxx.asm 125[225] undefined symbol 'halfsec'
    Error xxx.asm 126[225] undefined symbol 'halfsec'
    Error xxx.asm 128[225] undefined symbol 'halfsec'
    Error xxx.asm 129[225] undefined symbol 'unsec'
    Error xxx.asm 137[225] undefined symbol 'interr'

    As for me I can not understand those results at this stage and have no idea what was wrongin my code. Would you be so kind to look at my sourse code and help me to fix this problem in order to continue my project. Thank you inadvance and any ideas are appresiated.

    Here is the code example for my project:

    @ DEVICE pic16F628A, XT_OSC
    @ DEVICE pic16F628A, WDT_ON
    @ DEVICE pic16F628A, PWRT_ON
    @ DEVICE pic16F628A, MCLR_OFF
    @ DEVICE pic16F628A, BOD_ON
    @ DEVICE pic16F628A, LVP_OFF
    @ DEVICE pic16F628A, CPD_OFF
    @ DEVICE pic16F628A, PROTECT_OFF

    DEFINE OSC 4
    define INTHAND Myint ' Define interrupt handler

    counter var word 'to operate with unsec variable in main program

    wsave var byte $20 system
    ssave var byte bank0 system
    psave var byte bank0 system

    halfsec var byte
    unsec var word
    interr var byte

    halfsec = 0 'clear the time variables
    unsec = 0
    interr = 0

    INTCON = %11000000 'enable GIE and PEIE
    T1CON = %00110101 'Configure TMR1 with clock/4 and prescaler 1/8
    PIE1.0 = 1 'enable interrupt TMR1 overflow

    goto Main ' Skip around interrupt handler

    ASM ; Assembly language interrupt handler
    ; Save W, STATUS and PCLATH registers
    Myint MOVWF wsave
    SWAPF STATUS,W
    CLRF STATUS
    MOVWF ssave
    MOVF PCLATH,W
    MOVWF psave
    ; Interrupt code
    MOVLW 221
    MOVWF TMR1L
    MOVLW 11
    MOVWF TMR1H
    BCF PIR1,0
    INC halfsec
    BTFSS halfsec,1
    GOTO xxx
    CLRF halfsec
    INC unsec
    ; Restore PCLATH, STATUS and W registers
    xxx MOVF psave,W
    MOVWF PCLATH
    SWAPF ssave,W
    MOVWF STATUS
    SWAPF wsave,F
    SWAPF wsave,W
    BSF interr,0 ;just a flag...
    RETFIE
    ENDASM

    Main: 'Start of the main program

    counter = unsec ' Or do something else...

    goto Main ' Return to the main program
    end ' End

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


    Did you find this post helpful? Yes | No

    Default

    Hi nupass,
    welcome to the forum.

    First, you really should start a new thread for this as it does not seem to have much to do with this one.
    Dave
    Always wear safety glasses while programming.

  6. #526


    Did you find this post helpful? Yes | No

    Default

    Nupass,

    Try putting under scores in front of your variable within the asm routine

    halfsec var byte
    unsec var word
    interr var byte

    Asm

    _halfsec
    _unsec
    _interr

    endasm

    It's in the manual

  7. #527
    Join Date
    Jan 2010
    Posts
    2


    Did you find this post helpful? Yes | No

    Thumbs up

    Dear Mark_S,
    Thank you for your welcome, I'am appresiated.
    So, I was followed by your suggestion, and put underscore at the beginning of my variables...

    ... then ... success!!!

    It is easier than to make a koffee, just you need some skills... Assembler for me it's a horroble thing...

    Well, you have been very helpfull and I have learned some...
    Thank you a lot ones again.

    To be conitue...

  8. #528
    Join Date
    Feb 2010
    Posts
    3


    Did you find this post helpful? Yes | No

    Default DT site down...

    Hi,

    I´m not being able to access Darrell´s website to download DT_INTS-14 (I already use INTS-18, which is great, but I´m working on a project which runs on a 16F628A this time). Can someone please attach the latest version of both INTS-14 and INTS-18 to this thread, so people can download even if the site is down?

    Thanks!

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


    Did you find this post helpful? Yes | No

    Default

    Here is the latest version 1.00 of DT_INTS-14. The link is to is site, which is back up. http://www.darreltaylor.com/DT_INTS-14/NEW_DT_INTS.zip

    More info on above:http://darreltaylor.com/DT_INTS-14/intro2.html
    Older version of above:http://darreltaylor.com/DT_INTS-14/intro.html

    and here is the latest version of DT_INTS-18 http://www.picbasic.co.uk/forum/showthread.php?p=82871
    More info on DTS_INTS-18: http://darreltaylor.com/DT_INTS-18/home.html

    Besides the webpages above, this post contains info about the time re-enter takes, which I did not see details of on Darrel's site.
    http://www.picbasic.co.uk/forum/show...7587#post17587
    Last edited by ScaleRobotics; - 6th February 2010 at 16:40.

  10. #530
    Join Date
    Feb 2010
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by scalerobotics View Post
    Here is the latest version 1.00 of DT_INTS-14. The link is to is site, which is back up. http://www.darreltaylor.com/DT_INTS-14/NEW_DT_INTS.zip

    More info on above:http://darreltaylor.com/DT_INTS-14/intro2.html

    and here is the latest version of DT_INTS-18 http://www.picbasic.co.uk/forum/showthread.php?p=82871
    Still down for me here in Brazil... Even tried do flush my DNS cache to make sure... Would you be kind enough to attach INTS-14 to your post, so I can continue working?

    Thanks!

  11. #531
    Join Date
    Feb 2010
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    Thanks. Now only the only file I still need is elapsed_int-14. Could you please upload that one as well?

    Thanks again!

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by younesmaia View Post
    Now only the only file I still need is elapsed_int-14. Could you please upload that one as well?
    I think the latest version of that is still this one: http://www.picbasic.co.uk/forum/show...7473#post17473

  13. #533


    Did you find this post helpful? Yes | No

    Question

    Am I the only one confused by the "ALL_INT -- Global Interrupts" interrupt source?

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


    Did you find this post helpful? Yes | No

    Default

    ALL_INT references the GIE bit (Global Interrupt Enable).
    You can use it like this ...
    Code:
    @  INT_ENABLE  ALL_INT
    @  INT_DISABLE ALL_INT
    Someone here wanted it, but frankly I think it's easier to just alias the bit, then do GIE = 1.

    You can not assign a Handler to ALL_INT as an Interrupt Source.
    <br>
    DT

  15. #535
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    Darrel,

    Thanks for the DT-INTS modules, it's an awesome piece of work. It makes interrupt handling so much easier !

    I found this topic because i got stuck using the DT-INTS-18 within code that i was compiling using the 8.43 version of mplab. I got the same error116 over and over again, except when i commented out DT-INTS includes and ASM piece. Microcode studio compiles the exact same code without any error ...

    However removing the -K# parameter did the trick, it compiles flawless, exept for the fact that the Mplab SIM can't SIM anymore.

    Did you ever discover a workaround or did you get some more info from melabs ?

    Best regards,

    UB

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


    Did you find this post helpful? Yes | No

    Default

    Yes I did.

    See this post for the MPLAB fix.
    http://www.picbasic.co.uk/forum/show...26&postcount=3
    <br>
    DT

  17. #537
    Join Date
    Apr 2006
    Location
    GearSweaterMountain, The Netherlands
    Posts
    52


    Did you find this post helpful? Yes | No

    Default

    wohoo Darrel, Thanks !

  18. #538
    Join Date
    Nov 2008
    Posts
    96


    Did you find this post helpful? Yes | No

    Default 12F683 code to 12F629

    Quote Originally Posted by Darrel Taylor View Post
    I like the 683 too. If for nothing more than the CCP module. Of course the extra RAM and program space is also handy.

    With the 629 only having 64 bytes of RAM,
    PBP uses 24-26 bytes
    and DT_INTS-14 and ReEnterPBP want 31 bytes of it (without T? vars)

    Which only leaves about 6-7 bytes for the program. Not much you can do with that.

    But, when using ASM interrupt handlers, DT_INTS-14 only needs 7 bytes of RAM, leaving around 38 bytes for the users program. Now that, is workable. It also uses less program space that way.

    You mentioned earlier that you only needed to toggle a pin in the interrupt, so you might take a look at this page...

    DT_INTS-14 (Assembly Language Interrupts)
    http://www.darreltaylor.com/DT_INTS-14/asm_ints.html

    The ToggleLED1: handler does just that. And if the other handlers aren't too tuff, you might still fit it in a 629.

    HTH,
    &nbsp; DT
    Hi Darrel,
    I tried this above tip to get back some RAM space to try put my old 12F683 code into a 12F629, but I get a persistent PBP error when I try to compile it.

    error[101] d:temp\8chppm~3.asm 450: Error: (ReEnterPBP must be INCLUDEd to use PBP type interrupts)

    I also fiddled the wsave value to get past other errors, but this one escapes me, due to not being very familiar with assembly I'd expect.

    Heres my ASM code at the start of the program, what did I mess up ?
    Thanks Martin
    'Interrupt driven 20mS timer for PPM frame timing. See also "my_handler". Uses Timer 1 interrupts.
    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 TMR1_INT, _my_handler, PBP, yes
    endm
    INT_CREATE ; Creates the interrupt processor
    INT_ENABLE TMR1_INT ; Enable Timer 1 Interrupts

    ENDASM

    T1CON = $1 ; TMR1ON
    '@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts

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


    Did you find this post helpful? Yes | No

    Default The Error says it all

    error[101] d:temp\8chppm~3.asm 450: Error: (ReEnterPBP must be INCLUDEd to use PBP type interrupts)

    'INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts
    \<-- commented

    INT_Handler TMR1_INT, _my_handler, PBP, yes

    Ahhh chuew ...
    DT

  20. #540
    Join Date
    Jan 2010
    Location
    PHILADELPHIA, PA - USA
    Posts
    34


    Did you find this post helpful? Yes | No

    Default Understanding RBC_INT... or not

    Hi,

    I've been trying vary to fully understand the RBC_INT interrupt handler in DT_INTS-18.pbp.

    So I wrote this little program, Created a simulator circuit model and also a similar hardware circuit.

    Here is the Code:
    Code:
    ' RBC TEST.BAS
    ' PIC 18F6480
    ' MPLAB IDE V8.40
    ' PBP V2.60
    ' Build Options: [-ampasmwin]
    ' RB4  Momentary Contact Button Goes High on Press,  10K Resistor to Ground
    ' RB5  Momentary Contact Button Goes High on Press,  10K Resistor to Ground
    ' RB6  Momentary Contact Button Goes High on Press,  10K Resistor to Ground
    ' RB7  Momentary Contact Button Goes High on Press,  10K Resistor to Ground
    ' RC6  22K ohm to RX on 57600-N-8-1 Serial Terminal
    
    INCLUDE "DT_INTS-18.bas"		; Include Darrel Taylor's Base Interrupt System for PIC18F [Version:3.4 (NOV 04, 2009)]
    
    DEFINE OSC 20
    DEFINE DEBUG_REG PORTC	
    DEFINE DEBUG_BIT 6 			
    DEFINE DEBUG_BAUD 57600
    DEFINE DEBUG_MODE 1 
    DEFINE  SHOWDIGITAL 1
    
    TRISB=%11111111
    ADCON0=%00000000
    ADCON1=%00001111
    
    BTN	  VAR	BYTE
    
    ASM
    INT_LIST  macro ; IntSource,  Label,      Type,  ResetFlag?
            INT_Handler RBC_INT, _DO_RBC_INT,   ASM,  yes	
        endm
        INT_CREATE
    ENDASM
    
    @  INT_ENABLE   RBC_INT
    
    DEBUG "INTERRUPT CREATED",10,13
    DEBUG "INTERRUPT ENABLED",10,13
    
    HOLD_HERE:
    DEBUG "WAITING FOR INTERRUPT",10,13
    PAUSE 2500
    GOTO HOLD_HERE
    
    DO_RBC_INT
    DEBUG "############### RBC INTERRUPT ACTIVATED #################",10,13
    
    MENU:
    PAUSE 200
    DEBUG "MENU - READ BUTTONS",10,13
    If PORTB.4 = 1 Then PAUSE 250: Goto DO_ENABLE
    If PORTB.5 = 1 Then PAUSE 250: Goto DO_DISABLE
    If PORTB.6 = 1 Then PAUSE 250: Goto DO_RETURN
    If PORTB.7 = 1 Then PAUSE 250: Goto DO_CLEAR
    GOTO MENU
    
    DO_ENABLE:
    DEBUG "RUNNING DO_ENABLE",10,13
    @ INT_ENABLE RBC_INT
    Pause 250
    GOTO HOLD_HERE
    
    DO_DISABLE:
    DEBUG "RUNNING DO_DISABLE",10,13
    @ INT_DISABLE RBC_INT
    PAUSE 250
    GOTO HOLD_HERE
    
    DO_RETURN:
    DEBUG "RUNNING DO_RETURN",10,13
    @ INT_RETURN
    PAUSE 250
    GOTO HOLD_HERE
    
    DO_CLEAR:
    DEBUG "RUNNING DO_CLEAR",10,13
    @ INT_CLEAR RBC_INT
    PAUSE 250
    GOTO HOLD_HERE
    
    END
    Here is the Circuit:


    There are 4 buttons connected to PORT B <4.7>
    Here are my observations:

    The first press of any button activates the RBC Interrupt and sends program to DO_RBC_INT subroutine, then on to MENU where it checks for button presses. This behaves exactly as I would expect it to.

    Now...After that....

    Pressing Button RB.4 [ENABLE] Runs the DO_ENABLE subroutine then the HOLD_HERE subroutine. At this point, the Interrupt handler seems to shut down as no Port B inputs activate the interrupt handler. I would expect the Interrupt to remain active.

    Pressing Button RB.5 [DISABLE] Runs the DO_DISABLE subroutine then the HOLD_HERE subroutine. The Interrupt handler is now disabled as expected.

    Pressing Button RB.6 [RETURN] Runs the DO_RETURN subroutine then the HOLD_HERE subroutine. It then sends program to DO_RBC_INT subroutine, then on to MENU. I would expect it to return to HOLD_HERE which is wherr the interrupt was originally activated

    Pressing Button RB.7 [CLEAR] Runs the DO_CLEAR subroutine. At this point, the Interrupt handler seems to shut down as no Port B inputs activate the interrupt handler. I would expect this to just clear the interrupt then await another RBC trigger.

    So it seems I can only activate the interrupt one time.

    It doesn't seem to matter whether I use ASM or PBP types or set Resetflag to yes, or no

    Can anyone shed light on what I'm doing wrong, or am I simply misinterpreting the function of the INT_* utilities.

    I'm just not sure if I've got a mistake, am staying up too late working on this stuff, or just really don't get it.

    Thanks,
    Bob
    Attached Images Attached Images  
    Attached Files Attached Files
    Wozzy-2010

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


    Did you find this post helpful? Yes | No

    Default

    The idea of an Interrupt, is that it Stops the normal flow of the program ... executes an Interrupt Service Routine (ISR) ... then RETURNs back to the same point it was at when it was Interrupted.

    You can't go back to the Main Loop without INT_RETURN'ing.
    In other words ... no GOTO HOLD_HERE.
    <br>
    DT

  22. #542
    Join Date
    Jan 2010
    Location
    PHILADELPHIA, PA - USA
    Posts
    34


    Did you find this post helpful? Yes | No

    Default Not understanding RBC_INT

    Darrel,

    Thanks for the quick reply.

    I made a cut & paste error in my last post.

    It should have stated:
    Pressing Button RB.6 [RETURN] Runs the DO_RETURN subroutine. It then sends program to DO_RBC_INT subroutine, then on to MENU. I would expect it to return to HOLD_HERE which is where the interrupt was originally activated.

    Pressing Button RB.7 [CLEAR] Runs the DO_CLEAR subroutine Then the HOLD_HERE. At this point, the Interrupt handler seems to shut down as no Port B inputs activate the interrupt handler. I would expect this to just clear the interrupt then await another RBC trigger.

    I agree that it should never get to the GOTO HOLD_HERE statement, at the end of DO_RETURN:, but should still end up in HOLD_HERE since that is where the program was was when the RBC_INT interrupt was initially activated.
    Wozzy-2010

  23. #543
    Join Date
    Nov 2008
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    error[101] d:temp\8chppm~3.asm 450: Error: (ReEnterPBP must be INCLUDEd to use PBP type interrupts)

    'INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts
    \<-- commented

    INT_Handler TMR1_INT, _my_handler, PBP, yes

    Ahhh chuew ...
    Hi,
    Sorry Darrel I'm even more confused from the reply. I interpreted your old post and the website info to mean that if I wasn't using PBP interrupts e.g. 'On Interrupt' that I could rem out the ReEnterPBP.bas include. I see I'm interpreting that post wrong.
    Can I take that reply to mean that in this case I can't do that, or does this mean I need to write the handler in ASM ?

    That's MR Ahhh Cheuw :-)

  24. #544
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default

    Hi,
    You can use Darrels routines with interrupt service routines written in assembly and/or BASIC. If the interrupt service routines you write are written in BASIC (PBP) you should declare them as type PBP in the INT_LIST AND you must INCLUDE ReEnterPBP.bas. If you write your interrupt service routines in assembly you declare them as Type ASM in in the INT_LIST and then ReEnterPBP file is NOT needed because you're not using ISR's written in BASIC. Anytime one or more of you ISR's are written in BASIC the ReEnterPBP file must be included, only when all handlers are in ASM can it be left out.

    ON INTERRUPT is the compilers own way of handling interrupts and has nothing to do with DT_Ints. You use either ON INTERRUPT or Darrels routines.

    /Henrik.

  25. #545
    Join Date
    Nov 2008
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    Thanks Henrik, that explanation is clear, concise, and fully understood now.

    cheers,
    Martin

  26. #546
    Join Date
    Jan 2010
    Location
    PHILADELPHIA, PA - USA
    Posts
    34


    Did you find this post helpful? Yes | No

    Default Understanding RBC_INT

    Well I think I've finally figured out some of the nuances of RBC_INT.
    I think the last example I tried to use was not a very good way to test it out.

    I tried to document this working code example in a way that's understandable and can be used as a template to build on.

    This is setup with PBP type interrupts using ReEnterPBP-18.bas, since I'm using PBP in the Interrupt handler, but ... it seems to work just fine when run as ASM type, and not including ReEnterPBP-18.bas. You can just uncomment out the appropriate lines to suit your needs.

    The thing that was giving me so much of a headache before was the need to read one of the Port B <4-7> registers prior to exiting the Interrupt handler. This ends the mismatch condition and allows the RB Port Change Interrupt Flag Bit to be cleared. Even though I was reading the Port B <4-7> registers frequently, it seems that using GOTO to enter the Interrupt handler exit subroutine, caused the Interrupt Flag Bit to reset.

    Program operation:
    This Program uses DEBUG to send status comments to a 9600 Buad Serial ASCII Terminal on PORTC.6
    On first press of any of the PORTB<4-7> buttons, the program enters the interrupt handler.
    The Interrupt Handler, continuously reads the buttons.
    Buttons 1,2 & 3 just display a status message. You could put any subroutine in place of the DEBUG Statement.
    Button 4 gracefully exits the interrupt handler.
    At this point, RBC_INT is reset and awaiting any PORTB<4-7> button press again to reenter the Interrupt handler.


    Anyway here's the Code and a schematic of the setup... I hope this helps someone who's struggling with RBC_INT like I was.
    The ZIP file attachment has the code, and copies of the version of DT_INTS-18.bas and ReEnterPBP-18.bas that are included.

    Bob W.

    Code:
    ' RBC TEST.BAS
    ' Bob Wozniak
    ' PIC 18F6480 @ 20 MHZ
    ' MPLAB IDE V8.40  /  PBP V2.60  /  Build Options: [-ampasmwin]
    ' RB4  Momentary Contact Button Goes High on Press,  10K Resistor to Ground
    ' RB5  Momentary Contact Button Goes High on Press,  10K Resistor to Ground
    ' RB6  Momentary Contact Button Goes High on Press,  10K Resistor to Ground
    ' RB7  Momentary Contact Button Goes High on Press,  10K Resistor to Ground
    ' RC6  22K ohm to RX on 57600-N-8-1 Serial Terminal
    ' This program created to check Port-B Change Interrupts
    
    INCLUDE "DT_INTS-18.bas"		  ; Include Darrel Taylor's Base Interrupt System for PIC18F [Version:3.4 (NOV 04, 2009)]
    INCLUDE "ReEnterPBP-18.bas"      ; Need to include if using PBP type interrupts
    
    DEFINE OSC 20
    
    DEFINE DEBUG_REG PORTC	' SETUP DEBUG to view output on 9600 BAUD ASCII Terminal on PORTC.6
    DEFINE DEBUG_BIT 6 			
    DEFINE DEBUG_BAUD 9600
    DEFINE DEBUG_MODE 1 
    
    I VAR WORD
    X VAR BYTE
    
    ASM
    INT_LIST  macro ; IntSource,  Label,             Type, ResetFlag?
    ;       INT_Handler RBC_INT, _RBC_INT_HANDLER,   ASM,  no             ; use for ASM type interrupts
            INT_Handler RBC_INT, _RBC_INT_HANDLER,   PBP,  no             ; use for PBP type interrupts
        endm
        INT_CREATE
    ENDASM
    @ INT_ENABLE   RBC_INT
    
    
    
    HOLD_HERE:          ' **** This subrouting loops continuously and waits for button press to activate RBC interrupt handler
    IF I = 0 THEN DEBUG 10,13,10,13,"HOLDING FOR PORTB <4-7> BUTTON PRESS to ACTIVATE INTERRUPT",10,13 : I = 1
    PAUSE 10
    GOTO HOLD_HERE
    
    
    
    RBC_INT_HANDLER:     ' **** Program jumps here when ANY PORTB.4 thru PORTB.7 are changed ****
    DEBUG "############### RBC INTERRUPT ACTIVATED #################",10,13
    PAUSE 250    ' This pause allows time for button debounce - needs to be here unless immediate read of interrupt button req'd
    
    
    READ_BUTTONS:        ' **** Program cycles reading buttons, until button 4 is pressed ****
    If PORTB.4 = 1 Then DEBUG "BUTTON 1 PRESSED",10,13
    If PORTB.5 = 1 Then DEBUG "BUTTON 2 PRESSED",10,13
    If PORTB.6 = 1 Then DEBUG "BUTTON 3 PRESSED",10,13
    If PORTB.7 = 1 Then DEBUG "BUTTON 4 PRESSED - EXITING",10,13 : I = 0 : GOTO END_RBC_INT
    PAUSE 5  
    GOTO READ_BUTTONS
    
    
    END_RBC_INT:        ' **** this subroutine gracefully exits the interrupt handler and resets for next RBC event ****
    PAUSE 250              ; This pause allows time for button debounce - needs to be here or interrupt will immediatly reactivate
    DEBUG "################ EXITING RBC INTERRUPT HANDLER ############",10,13
    
    X = PORTB.7            ; NOTE: Prior to returning from RBC Interrupt, you MUST read at least 1 PORTB <4-7> to end
                           ; the mismatch condition and allow the RB Port Change Interrupt Flag Bit to be cleared.
                           ; If not here, the interrupt will immediatly reactivate if using the GOTO END_RBC_INT statement.
    @ INT_CLEAR RBC_INT
    @ INT_ENABLE RBC_INT
    @ INT_RETURN
    END

    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by WOZZY-2010; - 20th February 2010 at 06:54. Reason: clarify
    Wozzy-2010

  27. #547
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default

    Hi Bob.

    I think you must be very quick on the 4th button to exit (less that 250ms plus the debug delay). If you hold the button longer the ISR will activate again,won't it?

    Also the:

    @ INT_CLEAR RBC_INT
    @ INT_ENABLE RBC_INT

    at the end of the ISR are not necessary as they are handled by the DT_Ints, right?

    Ioannis

  28. #548
    Join Date
    Jan 2010
    Location
    PHILADELPHIA, PA - USA
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Ioannis View Post
    I think you must be very quick on the 4th button to exit (less that 250ms plus the debug delay). If you hold the button longer the ISR will activate again,won't it?
    Ioannis...You're right about this. the 250 mS delay is fine on the simulator, but is a little too short to be reliable with real hardware buttons. 400-600 is a better number for use on the hardware.

    Quote Originally Posted by Ioannis View Post
    Also the:
    @ INT_CLEAR RBC_INT
    @ INT_ENABLE RBC_INT
    at the end of the ISR are not necessary as they are handled by the DT_Ints, right?
    Thanks for pointing this out...it seems to be somewhat dependent on the value of the DT_INT ResetFlag Here's what I found:

    Disabling @ INT_CLEAR RBC_INT
    ResetFlag = yes - no change to program operation
    ResetFlag = no - Interrupt reactivates again immediately
    So the @ INT_CLEAR RBC_INT is dependent on the ResetFlag setting

    Disabling @ INT_ENABLE RBC_INT
    ResetFlag = yes - no change to program operation
    ResetFlag = no - no change to program operation
    So the @ INT_ENABLE RBC_INT is not necessary.

    I also now realize that I still haven't quite figured out the how INT_DISABLE RBC_INT effects the Interrupt handler in it's different states.

    Thanks,
    Bob W.
    Wozzy-2010

  29. #549
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default

    Why do you care so much about Enable/Disable flags? All these are taken care by Darrel in his routines, so normally you don't have to deal with them.

    Just do as his examples show and you are OK.

    In the extreme case you want some control as to when the interrupts are re-enabled, just use the @INT_ENABLE or @INT_DISABLE commands locally.

    Also the simplistic debouncing of a button with time delay is not very elegant and is not recommended as it can delay the program execution.

    Ioannis

  30. #550
    Join Date
    Jan 2010
    Location
    PHILADELPHIA, PA - USA
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Ioannis,

    Quote Originally Posted by Ioannis View Post
    Why do you care so much about Enable/Disable flags? All these are taken care by Darrel in his routines, so normally you don't have to deal with them.
    I'm really just trying to fully understand this particular interrupt. It's a good learning exercise for me before I go on to other interrupts. I am learning that Darrel's routines are actually much easier to use and sensible than I thought, before I thoroughly confused myself by looking at it in this much detail.

    Quote Originally Posted by Ioannis View Post
    Also the simplistic debouncing of a button with time delay is not very elegant and is not recommended as it can delay the program execution.
    As I'm really pretty new to this, I'd be very interested to know what is your recommendation for debouncing. Are you talking about a hardware, or a software solution?

    For my current application, the interrupt is just used to jump out of the main program to enter a set up menu. So the main program is on hold and nothing is time critical. This whole RBC_INT study is just a tangent that I went off on, when I didn't understand why the stuff that I had cut & paste from the examples didn't behave as I expected.

    Thanks again,
    Bob W.
    Wozzy-2010

  31. #551
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default

    Well, the idea is to use the interrupts, both with Port Interrupt on Change and Timer.

    On the first interrupt from your button, you start the timer. If you have multiple interrupts from the same button and the timer stil runs, just drop them.

    If the timer interrupt occurs, and the button is still pressed, then you can confirm that is really pressed, setting a flag.

    Hope this helps a little.

    Ioannis

  32. #552
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Question Diolan Bootloader, 18F4550, DT_INTS-18

    I have a small test board that has an ICSP and a USB connection to a pic 18f4550. I have a reset button on the MCLR and a second button on portb.1. An led is connected to portb.0

    The ICSP is used to program a bootloader onto the chip. Then USB is used to add the user program.

    I have loaded the Diolan bootloader onto this chip and it is working.

    I can make a test program in PBP 2.6 that flashes the LED on port b.0
    like this: The Bootloader required code to start at 0x800

    Code:
    DEFINE OSC 48
    DEFINE RESET_ORG 0x800
    ' Example program to blink an LED connected to PORTB.0 about 
    ' once a second
    
    Main:   
       High 0          ' Turn on LED connected to PORTB.0
       Pause 500       ' Delay for .5 seconds
    
       Low 0           ' Turn off LED connected to PORTB.0
       Pause 500       ' Delay for .5 seconds
    
       Goto Main       ' Go back to loop and blink LED forever
       End
    The above program works as expected. So the next step was to try the DT_INTS-18 with the bootloader...the code appears to load into the PIC fine, but after reset there is a pause of about 5 seconds then the chip shows up as an un-recognized USB device but does not enter the bootloader mode. To enter bootloader mode the PB on portb.1 is held down during power-on/reset. OR the user application can branch to 0x0016.

    It appears the program is branching somewhere to restart the bootloader code since the pic shows up as an unrecognized USB device. It should not show up at all after the code is loaded since I don't have any usb code in the user app listed below.

    Here is my test program with the DT_INTS-18 that is not working...
    Code:
        DEFINE OSC 20          
        DEFINE RESET_ORG 0x800  
                              
    INCLUDE "DT_INTS-18.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"     ' Include if using PBP interrupts
    
    LED1   VAR  PORTB.0
    
    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

    Any thoughts on why it's not blinking the led using the DT_INTS-18 code and running off into la la land?

    ADDED: I am using the MPASM assembler as well.

    Thanks
    Tom
    Last edited by vamtbrider; - 25th March 2010 at 20:28. Reason: Added Assembler info

  33. #553
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Does it work if you disable A/D on RB0?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  34. #554
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Odd

    I added the port configuration and acon register configs. That has an effect...
    The bootloader never leaves the bootloader mode to run the user app.

    if I comment out the Hardware configuration section and compile I can load the code via the bootloader, the device disappears from the USB list and then ~10seconds later I get the USB device not recognized.

    I have reloaded the led test program just to make sure the bootloader and chip are still working and they are. Very puzzling, but the registers do seem to have an effect.

    Nothing in the DT_INT writes to EEPROM 0x00? If there is a 5A there then the bootloader thinks its still in boot mode.

    Code:
        LED1   VAR  PORTB.0
        
        DEFINE OSC 20          
        DEFINE RESET_ORG 0x800  
        
        INCLUDE "DT_INTS-18.bas"        ' Base Interrupt System
        INCLUDE "ReEnterPBP-18.bas"     ' Include if using PBP interrupts                                           
    
        '   Hardware configuration
        '   ======================    
            '
            '   I/O and PORTs
            '   -------------  
        PORTB   =   0
        PORTC   =   0
        PORTD   =   0
        PORTE   =   0
        TRISB   =   %00000000       '<2-1> Inputs
        TRISC   =   0
        TRISA   =   0
        TRISD   =   0
        TRISE   =   0
            '
            '   A/D converter
            '   -------------       
        ADCON0  =   %00000000       ' A/D converter off     
        ADCON1  =   %00001111       ' All Digital Inputs
     '   ADCON2  =   %00000000 
                               
    
    
    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 10  
    GOTO Main
    
    '---[TMR1 - interrupt handler]--------------------------------------------------
    ToggleLED1:
         TOGGLE LED1
    @ INT_RETURN
    Still puzzled...

  35. #555
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    This hardware config give the same results as the original issue...ie the LED does not blink and the code appears to run off into la la land. Not sure how it is being detected as a usb device with the DT_INTS-18 code.

    Code:
        '   Hardware configuration
        '   ======================    
            '
            '   I/O and PORTs
            '   -------------  
        PORTB   =   0
        PORTC   =   0
        PORTD   =   0
        PORTE   =   0
        TRISB   =   %11111110       '<7:1> Inputs
        TRISC   =   0
        TRISA   =   0
        TRISD   =   0
        TRISE   =   0
            '
            '   A/D converter
            '   -------------       
        ADCON0  =   %00000000       ' A/D converter off     
        ADCON1  =   %00001111       ' All Digital Inputs
        ADCON2  =   %00000000
    I have two port b pins connected together as part of the ICSP and 2 others connected for inputs off a single PB. Setting the TRISB to FE is what got me back to the original problem.

  36. #556
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    I've never used this loader, but I did take a quick peek at the source files.

    Try this;
    Code:
        DEFINE OSC 20          
        DEFINE RESET_ORG 0x800  
        
        INCLUDE "DT_INTS-18.bas"        ' Base Interrupt System
        INCLUDE "ReEnterPBP-18.bas"     ' Include if using PBP interrupts                                           
    
        LED1   VAR  PORTB.0
        
    '   Hardware configuration
        '   ====================== 
        ADCON1  =   %00001111       ' All Digital Inputs                         
    
    
    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 10  
    GOTO Main
    
    '---[TMR1 - interrupt handler]--------------------------------------------------
    ToggleLED1:
         TOGGLE LED1
    @ INT_RETURN
    Remove power. Place a jumper from PORTE.0 to ground. Power up & load the above after compiling it.

    After programming it with the loader, power down. Move the jumper on PORTE.0 to Vcc, and power up.

    Does it work now?
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  37. #557
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default Same result

    If I don't have the TRISB config the bootloader never enters the user program mode.

    I added the TRISB = %1111110 and it enters the user program but still shows an undetected USB device after a few seconds and the LED on PORTB.0 is still not blinking.

    One more piece of info, I am getting power from the USB port on my laptop. Even though the user program is not using USB I am "stealing" power for this test setup from the USB port. i.e. I download the program to the bootloader through the PIC USB and leave the cable connected to power the board for testing.

    It doesn't look like anything in the DT_INTS would be triggered from activity on the USB port since I have not explicitly configured the USB_INT. The PIC is certainly seeing a request from the PC since its connected to the PIC circuitry and that could be why I get the USB device not recognized...although I don't get that when i am running just the Blink program using PAUSE 500 statements.

    When I get home later tonight I will load this program directly on the PIC through the ICSP without the bootloader to verify my setup is happy. Then I will try the bootloader again and use an external power supply instead of the USB power.

    ADDED: I have reconfigured the Bootloader to use PORT B.1 instead of Diolan's default of PortE.0. My end application will use Port B.1 so I built this test board assuming portb.1 would work.
    Last edited by vamtbrider; - 25th March 2010 at 22:53. Reason: Added Bootloader Jumper Information

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


    Did you find this post helpful? Yes | No

    Default

    Try adding ...
    Code:
    DEFINE LOADER_USED 1
    DT

  39. #559
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Pheeeewwww! I do NOT like that loader at all.

    I put one together for you here using the Microchip USB HID boot-loader. Give this one a shot. It works 100% with DT_INTS-18.

    I modified the original C18 loader file so you can switch between the external crystal & internal osc at run-time to switch back-and-forth to various speeds.

    Use a 20MHz crystal, 18F4550, and you should have no problems at all with the loader or DT_INTS-18.

    Of course you'll need to download & install the Microchip HID USB loader PC app, but I find that one WAY nicer, and easier to use than the Diolan thing.
    Code:
    '****************************************************************
    '*  Name    : USB_TST.BAS                                       *
    '*  Author  : B. Reynolds                                       *
    '*  Notice  : Copyright (c) 2010 http://www.Rentron.com         *
    '*          : All Rights Reserved                               *
    '*  Date    : 3/25/2010                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : Using the Microchip USB HID Boot-Loader with PBP  *
    '*          : and DT_INTS.                                      *
    '****************************************************************
        
       ' Using the Microchip MCHPFSUSB v2.1 HID USB Bootloader with PBP & DT INTS.
        
       ' Place a 10K pull-up on RB4 with a switch to ground RB4 when pressed. 
        
       ' Loader mode. Press & hold switch on RB4, then press/release reset switch on /MCLR.
       ' Now release switch on RB4.
        
       ' LEDs on PORTD.0 & D.1 will blink on/off quickly showiing you're in loader mode
       ' and the MCHPFSUSB v2.1 HID PC bootloader software should now recognize your board.
        
       ' Open & load your compiled code, with the loader software, then press/release
       ' the switch on /MCLR, or click Reset Device on the loader software.
       
       ' Your code should now be running. 
        
       DEFINE OSC 48                   ' Loader configured for 20MHz OSC on USB board
       DEFINE RESET_ORG 0x1000         ' User code start location for HID loader  
        
       INCLUDE "DT_INTS-18.bas"        ' Base Interrupt System
       INCLUDE "ReEnterPBP-18.bas"     ' Include if using PBP interrupts                                           
    
       LED1   VAR PORTD.0
       Loops  VAR BYTE
        
       '   Hardware configuration
       '   ====================== 
       ADCON1  =   %00001111       ' All Digital                         
    
    
    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
    
       OSCCON = %01110000     ; Switch to internal whenever you want by just
                              ; flipping OSCCON.1 to 1.
                              ; To run at 48MHz, flip OSCCON.1 back to 0..
    Main:
       FOR Loops = 1 TO 6    ' we'll run at 48MHz here
         TOGGLE PORTD.1
         Pause 500
       NEXT Loops
      
       OSCCON.1 = 1          ' we'll run at 8MHz on internal osc here 
       FOR Loops = 1 TO 6
         TOGGLE PORTD.1
         Pause 500
       NEXT Loops
       
       OSCCON.1 = 0          ' flip switch back to 48MHz
       GOTO Main
    
    '---[TMR1 - interrupt handler]--------------------------------------------------
    ToggleLED1:
       TOGGLE LED1
    @ INT_RETURN
    
        END
    Some day when I have time I might figure the other one out, but this took a fraction of the time to change & test.
    Attached Files Attached Files
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  40. #560
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    I think I have two problems.

    One the jumper for bootloader mode is a PB that will tie portb.1 and 2 to ground when pressed. Walking through the bootloader code with the MPLAB debugger the portb inputs are not always on. Some times they are and sometimes they are not. I enabled the pull ups through the INCON2<7> but that doesn't seem to help. So I need to figure that out first.

    A few times I have been able to get the DT_INTS-18 code with the blinky light to load into the PIC via the bootloader while still in debug mode in MPLABS. This has lead to the second problem.

    When the interrupt comes in the code jumps to 0x008 which has a GOTO 0x808.
    At 0x808 is another GOTO 0x998

    running through the interrupt eventually gets to the code below:

    Code:
    1122   08C2    C017             MOVFF usb_sm_state, 0x90               
      1123   08C4    F090             NOP                                    
      1124   08C6    C018             MOVFF usb_sm_ctrl_state, 0x91          
      1125   08C8    F091             NOP                                    
      1126   08CA    C019             MOVFF usb_active_cfg, 0x92             
      1127   08CC    F092             NOP                                    
      1128   08CE    C01A             MOVFF usb_alt_intf, 0x93               
      1129   08D0    F093             NOP                                    
      1130   08D2    8022             BSF [0x22], 0                          
      1131   08D4    B414             BTFSC [0x14], 0x2                      
      1132   08D6    EF74             GOTO 0x8e8                             
      1133   08D8    F004             NOP                                    
      1134   08DA    C021             MOVFF 0x21, PCLATU                     
      1135   08DC    FFFB             NOP                                    
      1136   08DE    C020             MOVFF 0x20, PCLATH                     
      1137   08E0    FFFA             NOP                                    
      1138   08E2    501F             MOVF [0x1f], W                         
      1139   08E4    6AE0             CLRF BSR, ACCESS                       
      1140   08E6    6EF9             MOVWF PCL, ACCESS                      
      1141   08E8    C01E             MOVFF pSrc, PCLATU                     
      1142   08EA    FFFB             NOP                                    
      1143   08EC    C01D             MOVFF 0x1d, PCLATH                     
      1144   08EE    FFFA             NOP                                    
      1145   08F0    501C             MOVF [0x1c], W                         
      1146   08F2    6AE0             CLRF BSR, ACCESS                       
      1147   08F4    6EF9             MOVWF PCL, ACCESS                      
      1148   08F6    0004             CLRWDT                                 
      1149   08F8    A022             BTFSS [0x22], 0                        
      1150   08FA    EFB4             GOTO 0x968
    the program resets after executing the instruction at 08F4 - MOVWF PCL, ACCESS. It looks like the WREG has a value of 0xDC that it is trying to stuff into PCL.

    Basically the debugger stops stepping at that line, I click on the next line below it and select run to cursor the code restarts at 0x00. The bootloader checks the jumper, which is not there and then runs the app.

    So basically it looks like the code keeps running to the first interrupt and then resetting the PIC.


    I have attached a capture of the PIC Program Memory for what its worth.


    I also loaded just the DT_INTS blinky light program onto the PIC without the bootloader. Using the MPLABS debugger i am able to see that when the code gets to the MOVWF PCL, ACCESS instruction it moves 0x34 from WREG into the PCL and the program jumps to 0x0234. The code at 0x0234 looks like the TOGGLELED1: code to actually toggle port b.0.
    The code runs great without the bootloader.

    Comparing the two pieces of code it looks like the bootloader version should be branching to 0x9DC...but instead I think its running off the stack and resetting the PIC.

    I am now going to try and reload the DT_INTS with the bootloader and see if I can capture the PCL, PCLATH and PCLATU registers when the code attempts to move 0xDC into PCL. Hopefully I can see where it is really trying to go.

    Its kind of late here in VA so I may have to tackle this tomorrow night.

    Thanks for all the ideas so far.
    Tom
    Attached Files Attached Files

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

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