|
|
View previous topic :: View next topic |
Author |
Message |
vsmguy
Joined: 13 Jan 2007 Posts: 91
|
CONST configuration clarification required |
Posted: Fri Aug 14, 2009 12:50 am |
|
|
I did not understand this explanation:
Quote: |
CONST=READ_ONLY : Uses the ANSI keyword CONST definition, making CONST variables read only, rather than located in program memory.
|
What did it say again?
Some questions:
1. Where would the const variables be located then?
2. By RAM, does CCS mean the SRAM of the PIC?
3. By ROM, does CCS mean the Flash (where the executable code is burnt in) of the PIC?
4. Are there ANY scenarios where CCS stuffs data into the inbuilt EEPROM but makes that transparent to me, or do I have to always treat the inbuilt EEPROM as an external peripheral and thus use the eeprom library functions?
5 Can it be possible that CCS misreports the amount of ROM used by the code?
I just created a 70kb array and targeted the PIC18F2550 and CCS tells me that my code used only 1% RAM and 53% ROM?
In effect I should be using 200% of the available ROM! |
|
|
Ttelmah Guest
|
|
Posted: Fri Aug 14, 2009 2:45 am |
|
|
All 'intialised' values, _start_ in program memory (= flash = ROM). There is nowhere else to hold them. So:
char str[]="fred";
Puts 'fred' in the ROM (flash) to begin with.
Then the vaue is read during boot, and copied to RAM (since this is a RAM variable).
With 'const', using the default settings, the string is left in the ROM, and accessed there.
When you instead select 'READ_ONLY', the value is initialised into RAM, just like a RAM variable, but the 'write' functions for that variable are disabled.
You can still accidentally overwrite it, if you use pointer arithmetic, and start to access the wrong part of RAM.....
You can use the addressmod functions to place variables into EEPROM (either internal or external). Downsides, you must remember the very large time overhead associated with writing, and significant bulk to the code using this route.
If you place an array, _and never access the values in it, or only access a few values_, the compiler wll only store the values you actually access.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|