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,
Bookmarks