LP Instant Interrupts Error


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429

    Default LP Instant Interrupts Error

    Hi All,

    When I try to use DT's instant interrupts with both high and low priority interrupts on my 18F1320 I get the error:

    ERROR: Unable to fit variable LP_Vars

    I am using only 24 byte variables and 4 bit variables, so its not like ive filled up the RAM.

    After some testing, I've found that if I remove large sections of code, it will work. But I am nowhere near filling the flash memory, so i'm at a loss.

    Anyone have any ideas.

    To be clear, it works fine with only high priority ints, but wont compile with both high and low.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

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


    Did you find this post helpful? Yes | No

    Default

    What file versions of ReEnterPBP-18.bas and ReEnterPBP-18LP.bas are you using?

    The 18F1320 has 256 bytes of ram, and utilization should look like this.
    Code:
    PBP's system     26 bytes
    DT_INTS-18       26
    ReEnterPBP-18    68
    ReEnerPBP-18LP   68
                    ---------
                    188 bytes
    
    User Vars        25 bytes
    		---------
                    213 total
    
    Remaining RAM    43 bytes
    Are your variables in an array?
    Are they being specified in a particular Bank?

    Do you have "Complex Formulas" in your program ... If statements with 10-15 AND/OR's, or math formulas with lots of parenthesis?

    PBP creates extra system variables for complex math or logical conditions.
    <br>
    DT

  3. #3
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    What file versions of ReEnterPBP-18.bas and ReEnterPBP-18LP.bas are you using?
    DT_INTS-18 v3.3
    ReEnterPBP-18 v1.4
    ReEnterPBP-18LP v1.4

    Quote Originally Posted by Darrel Taylor View Post
    Are your variables in an array?
    Are they being specified in a particular Bank?
    nope and nope.

    Quote Originally Posted by Darrel Taylor View Post
    PBP creates extra variables for complex math or logical conditions.
    That must be what's causing my problem. It compiles OK when I take out a couple of fairly large SELECT CASE statements (one with 20 cases and the other with 12 cases). I guess i'll try to re-write my code so it will use less background PBP vars.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

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


    Did you find this post helpful? Yes | No

    Default

    The select case itself shouldn't add anything, no matter how many cases there are.

    But maybe the code in those cases ???
    <br>
    DT

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


    Did you find this post helpful? Yes | No

    Red face

    Whoops!

    Wait a minute.
    There I was asking you about file versions, and it turns out I was compiling with the wrong files.

    Ok, I'm getting can't fit errors too.
    I'll figure it out and get back.
    <br>
    DT

  6. #6
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Thanks DT.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

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


    Did you find this post helpful? Yes | No

    Default

    It looks like PBP has a bit of a problem with jigsaw puzzles.
    There really is room left in RAM, but PBP can't seem to fit the pieces together.

    The 256 bytes of RAM, are divided into BANKA and BANK0.
    Technically, from the PIC's point of view, it's all BANK0, and BANKA resides in the lower 128 bytes of BANK0.
    But PBP treats it like 2 separate banks.

    And for some reason, a BANK0 modifier messes up it's puzzle solving ability.

    For instance ...
    I've removed all the code from the programs, and only retained the variable declarations, which looks something like this.
    Using 18F1320.
    Code:
    ; PBP system uses 26 bytes
    INT_System  VAR BYTE[26] ; from DT_INTS
    HP_Vars     VAR WORD[34] ; from ReEnterPBP-18
    LP_Vars     VAR WORD[34] ; from ReEnterPBP-18LP
    UserVars    VAR BYTE[25] ; vars declared in user's program
                             ; Total = 213 bytes, 43 bytes remaining
    
    RAMleft     VAR BYTE[43] ; use up remaining RAM
    The above compiles fine and uses up all 256 bytes of memory.
    So, all's well and good. You can add up any combination of arrays, bytes and words to fill up the RAM.

    Now let's remove the 43 byte RAMleft variable so there's plenty of room available.
    Then add a single byte variable, and specify BANK0 ...
    Code:
    ; PBP system uses 26 bytes
    INT_System  VAR BYTE[26] ; from DT_INTS
    HP_Vars     VAR WORD[34] ; from ReEnterPBP-18
    LP_Vars     VAR WORD[34] ; from ReEnterPBP-18LP
    UserVars    VAR BYTE[25] ; vars declared in user's program
                             ; Total = 213 bytes, 43 bytes remaining
    
    ;RAMleft     VAR BYTE[43] ; use up remaining RAM 
    Bank0var    VAR BYTE BANK0
    When you compile the above ... you get an "Unable to Fit" error.
    There's 43 bytes left, but it couldn't fit 1 byte.
    Well actually, it can't fit UserVars now either. If you comment UserVars it will compile.

    Interestingly, if you then specify BANK0 for the UserVars, it can fit it again.
    Code:
    ; PBP system uses 26 bytes
    INT_System  VAR BYTE[26] ; from DT_INTS
    HP_Vars     VAR WORD[34] ; from ReEnterPBP-18
    LP_Vars     VAR WORD[34] ; from ReEnterPBP-18LP
    UserVars    VAR BYTE[25] BANK0 ; vars declared in user's program
                             ; Total = 213 bytes, 43 bytes remaining
    
    ;RAMleft     VAR BYTE[43] ; use up remaining RAM 
    Bank0var    VAR BYTE BANK0
    And any additional variables will usually only fit if specified in BANK0.

    I've tried many variations of arrays, single bytes and combinations of both.
    It always comes down to whether ANY variables are specified in BANK0, anywhere in the program.
    After that, it won't automatically put anything else in BANK0, even after BANKA is full.

    For all the other chips with more RAM banks than a 1320, DT_INTS-18 "has to" specify some variables in BANK0.
    And because of the way PBP sorts the list of variables, LP_Vars usually gets the blame in the compiler error.
    I've tested all PBP versions back to 2.46 and the results are the same.

    Still with me ?<hr>
    So to try to actually answer your question ...

    In this circumstance (18F's with only 256 bytes), the best workaround I can see is to specify BANK0 for the variables in your program.

    You should be able to get another 43 bytes out of it.
    If you get close to the max, you may also need to manually put a couple in BANKA, just to squeeze in those last few.

    HTH,
    Last edited by Darrel Taylor; - 7th December 2009 at 01:05. Reason: wording and accuracy
    DT

  8. #8
    Join Date
    Nov 2005
    Location
    Perth, Australia
    Posts
    429


    Did you find this post helpful? Yes | No

    Default

    Wow, a very comprehensive analysis there DT.

    Specifying BANK0 for all of my vars worked like a charm.

    Thanks very much for your help. Once again you have gone above and beyond.
    "I think fish is nice, but then I think that rain is wet, so who am I to judge?" - Douglas Adams

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. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  3. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 20:02
  4. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 20:48
  5. Optimizing DIV
    By skimask in forum mel PIC BASIC Pro
    Replies: 41
    Last Post: - 22nd September 2008, 04:58

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts