Instant Interrupts - Revisited - Page 15


Closed Thread
Page 15 of 20 FirstFirst ... 5111213141516171819 ... LastLast
Results 561 to 600 of 773
  1. #561
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    Ok, it looks like the code is trying to goto 0xa34 in the attached file.
    It gets to 0x091C - MOVWF PCL, ACCESS and resets the PIC.

    Here are the values for PC:
    Code:
      Update      Address    Symbol Name      Value                      Binary     Char 
    
                     FE8     WREG                   0x34                  00110100    '4'
                     FF9     PCL                    0x1C                  00011100    '.'
                     FF9     PCLAT              0x0A341C 00001010 00110100 00011100  '.4.'
                     FFA     PCLATH                 0x34                  00110100    '4'
                     FFB     PCLATU                 0x0A                  00001010    '.'
    The code should be going to 0x0A34 but instead resets...It never actually moves the 0x34 from Wreg into the PCL.

    Any thoughts?

    Thanks
    Tom
    Attached Files Attached Files

  2. #562
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    With the Diolan USB loader;

    I would contact the author of your loader for help. His loader has extended instruction set enabled, and I don't think you're going to get PBP working on it with this enabled.

    If you're having problems with the Microchip HID loader I posted, it's something specific to your setup. It works rock-solid on the Microchip PICDEM FS USB board I tested it on.
    Last edited by Bruce; - 26th March 2010 at 08:54.
    Regards,

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

  3. #563
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    I will have to explore the Microchip bootloader a little more. I strayed away from it because I think it requires a .dll and I wanted a usb bootloader that would work with the standard microsoft drivers. The Diolan also uses encryption which is a very nice feature and the code size is slightly smaller.

    Plus I like a challenge...maybe if I can get this working it will give others another option for bootloaders and DT_INTS.

    So, on to what I have found today.

    From section 26.2.4 of the 18f4550 manual:

    Additionally, the Indexed Literal Offset Addressing
    mode may create issues with legacy applications
    written to the PIC18 assembler. This is because
    instructions in the legacy code may attempt to address
    registers in the Access Bank below 5Fh. Since these
    addresses are interpreted as literal offsets to FSR2
    when the instruction set extension is enabled, the
    application may read or write to the wrong data
    addresses.
    If I look at the .LST file for the blinky led program I see this:
    Code:
    00037 FLAGS                           EQU     RAM_START + 000h
      00000001            00038 GOP                             EQU     RAM_START + 001h
      00000002            00039 R4                              EQU     RAM_START + 002h
      00000004            00040 R5                              EQU     RAM_START + 004h
      00000006            00041 R6                              EQU     RAM_START + 006h
      00000008            00042 R7                              EQU     RAM_START + 008h
      0000000A            00043 R8                              EQU     RAM_START + 00Ah
      0000000C            00044 INT_Flags                       EQU     RAM_START + 00Ch
      0000000D            00045 RM1                             EQU     RAM_START + 00Dh
      0000000E            00046 RM2                             EQU     RAM_START + 00Eh
      0000000F            00047 RR1                             EQU     RAM_START + 00Fh
      00000010            00048 RR2                             EQU     RAM_START + 010h
      00000011            00049 RS1                             EQU     RAM_START + 011h
      00000012            00050 RS2                             EQU     RAM_START + 012h
      00000013            00051 wsave                           EQU     RAM_START + 013h
      00000014            00052 RetAddrH                        EQU     RAM_START + 014h
      00000017            00053 RetAddrL                        EQU     RAM_START + 017h
    Looking at the 2nd Capture.txt file I attached yesterday there are lots of MOVWF statements that reference the RAM areas above which are in RAM at locations under 0x5F.

    So a statement like MOVWF [0x14] is really MOVWF [FSR2+0x14] with the extended instruction enabled. This may then explain why the code jumps off into la la land and resets.

    I did not think to capture FSR2 last night during my debugging. I will do that tonight and see if it matches my theory. If it does then I think I will try to change the RAM_START to 0x060 so that the extended instruction engine will not use the FSR2 on the Ram addresses.

    Am I on the right path?

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by vamtbrider View Post
    I will have to explore the Microchip bootloader a little more. I strayed away from it because I think it requires a .dll and I wanted a usb bootloader that would work with the standard microsoft drivers.
    I think there are two usb bootloaders from microchip. One is a HID Bootloader. I don't think it requires any dll's. It is located inside the huge files that you download as a group. Once all the Microchip Application Libraries v2010-02-09 is installed, the .hex file is located here: C:\Microchip Solutions\USB Device - Bootloaders\HID - Bootloader

    I believe you can just bring the hidbootloader exe to a different computer, and program over the usb. But I have not fully tried it yet. I have only got to the point where my chip was regognized by a computer that has never had any microchip software loaded on it.

    I need to try the executeable.

  5. #565
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default

    The Diolan bootloader works as a HID USB device and my end app will eventually be a HID devices as well. If I get time this weekend I will try the Microchip HID bootloader, as Bruce indicated that maybe the more solid solution.

    I am looking at changing the statement in MPASM P18F4550.inc from

    Code:
    ACCESS  EQU  0
    to

    Code:
    ACCESS EQU  1
    This will allow the RAM definitions to stay the same and get past the extended instruction issues with f<0x5F. The draw back will be a lot of BSR changes. We'll see how that works out.

  6. #566
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    The major issue you have with the Diolan loader is that it has Enhanced CPU mode
    enabled. I.E. XINST = ON.

    So code compiled with PBP simply is not compatible, and will not run on the PIC as
    expected unless you disable Enhanced CPU mode.

    Here's a simple example you can try. Make sure you set XINST = OFF, then run this;

    Code:
    MyVar VAR WORD
    LED VAR PORTD.0 
    
    Loops:
     FOR MyVar = 0 TO 100
       High LED        
       GOSUB BLINK  
    
       Low LED       
       GOSUB BLINK  
     NEXT MyVar
     
       Goto Loops 
    
    BLINK:
        PAUSE 200
        RETURN
        
        End
    Now run the exact same code, but set XINST = ON and give it a whirl.

    Once you flip that switch to enable Enhanced CPU mode, ALL your code needs to be using
    the extended instruction set. Try it with ACCESS EQU 1 as well. Still no go.
    Last edited by Bruce; - 26th March 2010 at 19:32.
    Regards,

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

  7. #567
    Join Date
    Mar 2010
    Posts
    15


    Did you find this post helpful? Yes | No

    Default It works

    What I found interesting is that PicBasicPro compiles this code correctly for XINT on. Using brackets and leaving out the access parameter for addresses under 0x5F.

    The blinky light code I originally posted now runs fine with the Diolan bootloader. The trick I found was to clear the FSR2L and FSR2H registers as the first instructions in my program. I also set Access equ 1.

    I think the main issue was that I never initialized the FSR2 register to zero in my code. The Diolan bootloader uses FSR2 and it could have any value in it when the app code runs.

    Since that is the register used for indexed addressing when XINST is on it must be set to zero to allow legacy code to run. Setting FSR2 to zero places the access bank and SFR's in memory just as if XINST was 0. I found this info in the data sheet. Had to read it about 10 times to make sure I was following it correctly.

    The next challenge I am working on is to get the USB interrupts working with DT_INTS and the Diolan Bootloader. The USB_DEV.ASM and USB_HID.ASM use FSR2/INDF2 for indirect addressing and as a general register in several routines. Those will need to be modified to use FSR0/1 and INDF0/1 instead.

  8. #568
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default Found label after column 1 etc errors

    OK. I am pulling my hair off. Cannot think what might be wrong here.

    I get errors like Found label after column 1 (INT_CREATE) or Illegal opcode (RBC_INT) or Address label duplicated in second pass (INT_RETURN).

    The PIC® is F819, with DT-INTS-14 and MPASM of course. Also commented the confg line in the *.inc file as it can be seen on the attached files.

    Ioannis
    Attached Files Attached Files
    Last edited by Ioannis; - 20th April 2010 at 15:14.

  9. #569
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Did you forget these?

    INCLUDE "DT_INTS-14.bas"
    INCLUDE "ReEnterPBP.bas"
    Regards,

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

  10. #570
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default

    No Bruce. They are in pbp directory and the project too.

    It is not the first time I use these excellent routines.

    That is why I post here. I am almost driving myself in the la-la land with this!

    Ioannis

  11. #571
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Hi Ioannis,

    Strange. It compiles fine for me. Tried it with the old & new versions of DT_INTS!
    Attached Files Attached Files
    Last edited by Bruce; - 20th April 2010 at 17:16. Reason: Added file
    Regards,

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

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    Did you forget these?

    INCLUDE "DT_INTS-14.bas"
    INCLUDE "ReEnterPBP.bas"
    Compiles here as well, but I do get the same errors IF I leave the above lines out of the code. Are you sure the include lines are in your water?

  13. #573
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


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

  14. #574
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    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 20:55.

  15. #575
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,611


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

  16. #576
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,795


    Did you find this post helpful? Yes | No

    Default

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

    Ioannis

  17. #577


    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

  18. #578
    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.

  19. #579
    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 19:54. Reason: code box

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


    Did you find this post helpful? Yes | No

    Default

    Hi Bill,

    Are you using version 1.00 of DT_INTS-14.
    http://www.darreltaylor.com/DT_INTS-14/intro2.html (bottom of page)

    If so, try adding this define ...
    DEFINE INT_ENABLECLEARFIRST 0

    By default, the INT_ENABLE command clears the flag first before enabling.
    So, if there is an interrupt pending, it will be discarded.

    Adding the define tells it to NOT clear the flag first.
    It's only available in the 1.00 version.

    hth,
    DT

  21. #581
    Join Date
    Jun 2005
    Location
    West Australia
    Posts
    116


    Did you find this post helpful? Yes | No

    Default No change - no Int's.

    Hi Darrel,

    Thanks for your help.

    I am using ver 1.00 and added the new Define per your instructions - same result (no Int's).

    It compiles without errors (as before) and runs correctly in all other respects apart from an Interrupt taking place no matter how many times I trigger (or even hold the pin low).

    I'm not desperate for the fix so if it's not convenient for you I can wait, no problem.

    Kind regards,
    Bill

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


    Did you find this post helpful? Yes | No

    Default

    When I fixed your [code][/code] tags, something stuck out.

    The INT_CREATE line is in column 1.
    Is it like that in your program?
    It should be indented.
    <br>
    DT

  23. #583
    Join Date
    Jun 2005
    Location
    West Australia
    Posts
    116


    Did you find this post helpful? Yes | No

    Default Still NBG

    Hi Darrel,

    I don't know how that wasn't indented... anyway it made no difference.

    I also added
    Code:
    debug "x=",#INTCON.7,13,10
    in there to see if the GIE was being set - it was. Still no INT's.

    I may go back to blinky and add small sections one at a time to get my mind around this.

    Thanks and regards,
    Bill

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


    Did you find this post helpful? Yes | No

    Default

    Don't know why it's not working for you. I can't run it in ISIS cause there's too much missing.

    But I think this is one of those instances where you don't really need interrupts to do what you want.

    The INTF flag will be set when the INT input is triggered, whether you are using interrupts or not. And it stays latched until cleared in software.

    So at the end of your loop, after the FOR/NEXT, just check the INTF flag and if it's set, call the subroutine, and clear the flag before returning. No interrupts needed.

    hth,
    DT

  25. #585
    Join Date
    Jun 2005
    Location
    West Australia
    Posts
    116


    Did you find this post helpful? Yes | No

    Thumbs up You bewdy!

    Hi Darrel,

    Yes, it helped a lot - thank you.

    It is now fully functional and exactly what I want. Certainly was a case of me trying to over-engineer the requirement and overlooking the obvious, no interrupts needed only a check of the appropriate flag, as you diagnosed.

    I learnt a few things on the way - bonus! I expect your DT_INTS will now be a large part of my projects in future, I see how they can make things so much more efficient.

    Thanks again and best regards,
    Bill

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by wjsmarine View Post
    i learnt a few things on the way - bonus!
    SWEET!

    i expect your dt_ints will now be a large part of my projects in future, i see how they can make things so much more efficient.
    &nbsp;SWEET--ER!

    Cheers,
    &nbsp; &nbsp; DT

  27. #587
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257


    Did you find this post helpful? Yes | No

    Default

    Darrel,

    What I have is a timer1 servicing an interrupt every 10msec and a Usart RX interrupt when ever data comes in. Problem is that when the pic is off dealing with the usart interrupt, my timer1 is ignored until the usart interrupt is finished.

    Do you have a low priority interrupt version for 14Bit pics? eg ReEnterPBP-14LP.bas
    This could be the answer to my problem...



    Squib
    Last edited by Squibcakes; - 27th May 2010 at 02:02.

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


    Did you find this post helpful? Yes | No

    Default

    Nope.
    The ability to have Low Priority interrupts depends on the hardware, and 14-bit cores don't have it.

    I would suspect that you are using the RX interrupt to start reading a long string of bytes using HSERIN in the handler.
    If so, then it's sitting in the handler doing nothing while waiting for data to come in.

    For best speed, an RX interrupt should only retrieve 1 byte at a time, then exit the handler.
    It only takes a few uS that way.
    DT

  29. #589
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Nope.
    For best speed, an RX interrupt should only retrieve 1 byte at a time, then exit the handler.
    It only takes a few uS that way.
    I'm waiting for a string of NMEA chars to arrive into a huge data array.

    I'm not quite sure how to code the above interrupt process into a [wait(" "),data] style command. This is what I am using at the moment when the RX_INT interrupt fires....

    Code:
    WAIT_GLL:
    HSERIN 100,WAIT_GLL,[WAIT("GLL"), STR DATAIN\40\13]
    If I receive each byte and then do some byte checks to simulate the above syntax will the pic be fast enough to catch the sentance when it actually arrives or is the a better way?
    Squib

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


    Did you find this post helpful? Yes | No

    Default

    Squib,

    Sorry, I was trying to see if I could finish an NMEA sentence parser I've been toying with.
    But there's too much left to do.

    Are you only looking at the GLL sentence?

    My RX_INT handler for it is double buffered, so it can work on one sentence while receiving another.
    If it's only looking for the GLL sentence, it won't need the double buffer.
    DT

  31. #591
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    257


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Squib,
    My RX_INT handler for it is double buffered, so it can work on one sentence while receiving another.
    Hi DT,

    Is that in the current version of inst_ints or the one your working on now?

    I got my progy working by using the @ INT_DISABLE RX_INT command in the handler but is that really kosha or just sloppy programming? ;-)

    Yes I'm just looking for the one nea sentance at this time.

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


    Did you find this post helpful? Yes | No

    Default Help with assembly table lookup with DT INTS?

    Is there a way to use an assembly lookup table from within a DT INTS ASM interupt? When I try, the interrupt locks up on me. If I comment out the CALL SineTable, all is fine. I have tried it a few different ways, but no go so far.

    Code:
    INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System
    LOW  LED1     
    high led2     
    ASM
    
    INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler   TMR1_INT,   ToggleLED1,   ASM,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    
    T1CON = $31                  ; Prescaler = 8, TMR1ON
    @   INT_ENABLE  TMR1_INT     ; Enable Timer 1 Interrupts  
    
    Main:
        @ NOP
    GOTO Main
    
    '---[TMR1_INT - interrupt handler]------------------------------------------
    ASM
    
    ToggleLED1
            btg     _LED1               ; toggle the pin
            btg     _LED2
    StepLoop
            movf    _STEPCOUNT,W    ; Pass table offset via W
            call    SineTable    ; Get table value 
            movwf   CCPR1L
            decfsz  _STEPCOUNT,F    ; Next step
            goto    $+6
            movlw   d'32'
            movwf   _STEPCOUNT ;_STEPCOUNT    ; Load counter for 32 steps  
            NOP
            NOP
            NOP
            NOP
        INT_RETURN
    SineTable   
            addwf   WREG        ;added for pic18f each address is 16 bits
            addwf    PCL,F
            retlw   d'0'          ; Dummy table value
            retlw   d'128'        ; 0 degree, 2.5 volt
            retlw   d'148'
            retlw   d'167'
            retlw   d'185'
            retlw   d'200'
            retlw   d'213'
            retlw   d'222'
            retlw   d'228'
            retlw   d'230'        ; 90 degree, 4.5 volt
            retlw   d'228'
            retlw   d'222'
            retlw   d'213'
            retlw   d'200'
            retlw   d'185'
            retlw   d'167'
            retlw   d'148'
            retlw   d'128'        ; 180 degree, 2.5 volt
            retlw   d'108'
            retlw   d'89'
            retlw   d'71'
            retlw   d'56'
            retlw   d'43'
            retlw   d'34'
            retlw   d'28'
            retlw   d'26'        ; 270 degree, 0.5 volt
            retlw   d'28'
            retlw   d'34'
            retlw   d'43'
            retlw   d'56'
            retlw   d'71'
            retlw   d'89'
            retlw   d'108'
    ENDASM

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


    Did you find this post helpful? Yes | No

    Default

    You should be able to do that.

    But I think you need to initialize the STEPCOUNT variable, or put a CLEAR at the top.
    If it powers up with a value higher than 32, the table jump will throw it outside of the interrupt code.

    hth,
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Thanks for the help Darrel.

    I will look into it further. I had initialized stepcount to 32, then later to 8. Seems to get stuck after about two flashes of the led's.

    Walter

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


    Did you find this post helpful? Yes | No

    Default

    Maybe you need to set PCLATH before changing PCL?
    DT

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


    Did you find this post helpful? Yes | No

    Default

    Walter,

    Try this. It gives you a lot smaller table by packing two bytes into each word space. If you stick with the RETLW approach just uncomment the addwf WREG.

    Code:
    ASM
    SineTable   
      movlw UPPER Table1
      movwf TBLPTRU
      movlw HIGH Table1
      movwf TBLPTRH
      movlw LOW Table1
      movwf TBLPTRL
      movf _STEPCOUNT,W
      ;addwf WREG     ; uncomment only if using RETLW tables VS db
      addwf TBLPTRL
      TBLRD*
      movf  TABLAT, W
      return
     
    Table1
      db 0,128,148,167,185,200,213,222,228,230,228,222,213,200,185,167
      db 148,128,180,108,89,71,56,43,34,28,26,28,34,43,56,71,89,108
    ENDASM
    Regards,

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

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


    Did you find this post helpful? Yes | No

    Default

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

    Can somebody tell me what's wrong?

    Thanks

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


    Did you find this post helpful? Yes | No

    Default

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

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

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


    Did you find this post helpful? Yes | No

    Default

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

  40. #600
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default

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

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

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

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

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