|
|
View previous topic :: View next topic |
Author |
Message |
restman Guest
|
How many bytes a char use on program memory? |
Posted: Wed Nov 21, 2007 8:54 am |
|
|
Hi.
My problem is (if it is a problem); when i declare a variable as a constant, it uses 2 bytes on program memory. (i look at it in Proteus) Is this natural or is there any setting for this to use one byte?
Thanks for your helps... |
|
|
Ttelmah Guest
|
|
Posted: Wed Nov 21, 2007 9:25 am |
|
|
You don't say what processor?.
The answer varies with the chip.
On the older PIC12/16 chips, there is no ability to directly access program memory, so a single byte, is coded as the instruction:
RETLW n
Where 'n' is the value required. Here, a single byte will always use one _word_ of program memory.
On PIC16 chips where the program memory can be directly accessed, though the whole word can now be retrieved, the problem is that the word, is 14bits long, and hence can't hold two bytes. There have been programs posted here in the past, to encode two 7bit ASCII values, into one of these locations.
On the PIC18, the locations can now hold two bytes, but the bytes have to be 'word aligned' at the start of the declaration. So, if you store 5 bytes, it'll use just three words, but storing a single byte, will use one word (the same applies with the fourteen bit encoding programs mentioned above).
Best Wishes |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
|
|
|
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
|