I have some code for the PIC16F886 that when complied goes over the avilable RAM for the chip (368 bytes) when I can only account for around half that in the compiled code (My variables + GCB System Variables).
My question is how does GCB alloacte RAM greater than it seems is defined?
By deleting sections of code it seems to me crossing page boundrys causes this blowout of RAM.
If this is so is there any cunning tricks to reduce RAM usage?
10:20:43 G+Stool-COMPILE/ASSEMBLE
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Byte variables
Do not need any special commands to set them up - just put the name of the variable in to the command where the variable is needed.
String Variables
Strings are defined as follows:
'Create buffer variables to store received messages
Dim Buffer As String
String variables default to the following rules and the RAM constraints of a specific chip.
10 bytes for chips with less than 16 bytes of RAM.
20 bytes for chips with 16 to 367 bytes of RAM.
40 bytes for devices with more RAM than 367 bytes.
For chips that have less RAM then the required RAM to support the user define strings the strings (and therefore the RAM) will be NOT be allocated. Please reduce string size.
You cannot store a string 20 characters long in a chip with 16 bytes of RAM.
To change the default string size handled internally by the Great Cow BASIC compiler you add increase/decrease the default string size
'To define the default string size as the follows constant.
#define STRINGSIZE 24
Defining a length for the string is the best way to limit memory usage. It is good practice if you need a string of a certain size to set the length of a strings, since the default length for a string variable changes depending on the amount of memory in the microcontroller (see above).
To set the length of a string, see the example below:
'Create buffer variables to store received messages as 16 bytes long
Dim OutBuffer As String * 16
To place quotation marks (" ") in a string of text. For example:
She said, "You deserve a treat!"
Use the following method to show the string with the insertion of two quotation marks in a row as an embedded quotation mark. These two examples apply to all output methods like HerPrint, Print etc.
hserprint "She said, ""You deserve a treat!"" "
dim myString as string * 39
myString = "She said, ""You deserve another treat!"" "
hserprint myString
Variable Aliases
Some variables are aliases, which are used to refer to memory locations used by other variables. These are useful for joining predefined byte variable together to form word variables.
Alias are not like pointers in many languages - they must always refer to the same variable or variables and cannot be changed
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have some code for the PIC16F886 that when complied goes over the avilable RAM for the chip (368 bytes) when I can only account for around half that in the compiled code (My variables + GCB System Variables).
My question is how does GCB alloacte RAM greater than it seems is defined?
By deleting sections of code it seems to me crossing page boundrys causes this blowout of RAM.
If this is so is there any cunning tricks to reduce RAM usage?
10:20:43 G+Stool-COMPILE/ASSEMBLE
Can you attach your code?
Size of code is dependent on your code and which libraries.
What version of the compiler? v0.95.010?
Sorry, I thought I pasted the complier version.
Compiler Version: 0.95.010 2016-10-28 Program Memory: 3234/8192 words (39.48%) RAM: 346/368 bytes (94.02%) Chip: 16F886
I understand the size of code can vary, but is it the page boundrys that changes the size of RAM used?
Yes, One or two bytes but I would have to check the source code.
Attach your source and asm - let me look at the code you are producing please.
This is the best answer re using variables.
Byte variables
Do not need any special commands to set them up - just put the name of the variable in to the command where the variable is needed.
String Variables
Strings are defined as follows:
String variables default to the following rules and the RAM constraints of a specific chip.
10 bytes for chips with less than 16 bytes of RAM.
20 bytes for chips with 16 to 367 bytes of RAM.
40 bytes for devices with more RAM than 367 bytes.
For chips that have less RAM then the required RAM to support the user define strings the strings (and therefore the RAM) will be NOT be allocated. Please reduce string size.
You cannot store a string 20 characters long in a chip with 16 bytes of RAM.
To change the default string size handled internally by the Great Cow BASIC compiler you add increase/decrease the default string size
Defining a length for the string is the best way to limit memory usage. It is good practice if you need a string of a certain size to set the length of a strings, since the default length for a string variable changes depending on the amount of memory in the microcontroller (see above).
To set the length of a string, see the example below:
To place quotation marks (" ") in a string of text. For example:
Use the following method to show the string with the insertion of two quotation marks in a row as an embedded quotation mark. These two examples apply to all output methods like HerPrint, Print etc.
Variable Aliases
Some variables are aliases, which are used to refer to memory locations used by other variables. These are useful for joining predefined byte variable together to form word variables.
Alias are not like pointers in many languages - they must always refer to the same variable or variables and cannot be changed