View Full Version : LP Instant Interrupts Error
Kamikaze47
- 5th December 2009, 17:16
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.
Darrel Taylor
- 5th December 2009, 19:39
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.
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>
Kamikaze47
- 5th December 2009, 19:52
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
Are your variables in an array?
Are they being specified in a particular Bank?
nope and nope.
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.
Darrel Taylor
- 5th December 2009, 20:06
The select case itself shouldn't add anything, no matter how many cases there are.
But maybe the code in those cases ???
<br>
Darrel Taylor
- 5th December 2009, 21:29
Whoops!
Wait a minute.
There I was asking you about file versions, and it turns out I was compiling with the wrong files. :o
Ok, I'm getting can't fit errors too.
I'll figure it out and get back.
<br>
Kamikaze47
- 6th December 2009, 03:39
Thanks DT.
Darrel Taylor
- 6th December 2009, 21:41
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.
; 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 ...
; 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.
; 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,
Kamikaze47
- 7th December 2009, 09:13
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.
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.