Searching \ for 'Inefficient use of Program Memory in PIC16F877' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/memory.htm?key=memory
Search entire site for: 'Inefficient use of Program Memory in PIC16F877'.

Truncated match.
PICList Thread
'Inefficient use of Program Memory in PIC16F877'
1999\10\14@094903 by David Williams

flavicon
face
Hello all,
I have a question.  I have a bunch of data that is 14 bits in size.  I'm
using Hitech PIC-C so I've placed the data in an integer.  I've done
something like this:

const int data[256] = {0x2324,0x2425,0x3233, ..... };

So I compile and I notice that in the program memory ROM the data is
stored like this:

3F24 3F23 3F25 3F24 ....

Look at all that space that could be used.  My 256 array takes up 512
words of program memory.  Now my data is only 14 bits big.  Is there
anyway I can delcare a variable 14 bits in size such that my constant
table of data that is 256 14bit words big could be stored in 256 words of
program memory?

Same goes for charaters.  If I never plan to use characters with an ASCII
value greater than 127, then can I find some efficent way to store these
7bit characters in program memory without using 1 word per character.  Ie
stick two 7bit characters in 1 word of program memory.

Note:  I don't want to use the write to and read from program memory
capabilities of the PIC16F877 because that would just cause more code to
be writen and hence more program memory occupied.  Soemthing like the
const expression which stores values in ROM is what I'm looking for.

Thanks
Dave

1999\10\14@133611 by Byron A Jeff

face picon face
>
> Hello all,
> I have a question.  I have a bunch of data that is 14 bits in size.  I'm
> using Hitech PIC-C so I've placed the data in an integer.  I've done
> something like this:
>
> const int data[256] = {0x2324,0x2425,0x3233, ..... };
>
> So I compile and I notice that in the program memory ROM the data is
> stored like this:
>
> 3F24 3F23 3F25 3F24 ....
>
> Look at all that space that could be used.  My 256 array takes up 512
> words of program memory.  Now my data is only 14 bits big.  Is there
> anyway I can delcare a variable 14 bits in size such that my constant
> table of data that is 256 14bit words big could be stored in 256 words of
> program memory?

Nope. This is the standard. Each one of these is an actual instruction.
A RETLW with the 8 bit value to return.

{Quote hidden}

Well you can't really have it both ways. You can do it if you at least read
the program memory, if not write it. But if you plan to use the existing
mechanism, then you're stuck. BTW if you do implement read/write of program
memory, then the program cannot be transferred to anything other than other
16C87X family members.

This is the price of a harvard architecture machine. Data isn't really designed
to be stored in the program memory space.

BAJ

1999\10\14@180721 by Andy Kunz

flavicon
face
>const int data[256] = {0x2324,0x2425,0x3233, ..... };

I store big tables in EEPROM whenever possible.

Just had a neat application of it.  We're doing a TV interface for an MPI
Zenith set, and I have all kinds of messages to send to the screen during
test mode.

Not having enough ROM for it, I stuck them in EEPROM (we have 8Kx8 there).
The messages going to the set can now be in any language.  We have a
"world" compatible box without even trying!

Just a thought.

Andy

==================================================================
Eternity is only a heartbeat away - are you ready?  Ask me how!
------------------------------------------------------------------
spam_OUTandyTakeThisOuTspamrc-hydros.com      http://www.rc-hydros.com     - Race Boats
.....andyKILLspamspam@spam@montanadesign.com  http://www.montanadesign.com - Electronics
==================================================================

1999\10\14@185439 by paulb

flavicon
face
Byron A Jeff wrote:

>> Note:  I don't want to use the write to and read from program memory
>> capabilities of the PIC16F877 because that would just cause more code
>> to be writen and hence more program memory occupied.

> Well you can't really have it both ways.

 Said it in one!

>>  Something like the const expression which stores values in ROM is
>> what I'm looking for.

 I see the problem.  Read Program Memory is most certainly how you get
the data *out* of the memory again, but how do you *code* it into the
program.  The "DB" or whatever shoves it into RETLWs.

 It's an *assembler syntax* question, not a coding one, if that makes
sense.  I don't know the answer.   If necessary, I would fiddle the
object files to get the job done, but is there an easy way provided?
--
 Cheers,
       Paul B.

1999\10\17@114747 by Myke Predko

flavicon
face
Hi David,

use the "dw" assembler directive.

ie:

data  dw  0x02324, 0x02425, 0x03233...

It will store the data in the format you want into program memory and can be
read using the EEPROM program memory read commands.

myke
{Original Message removed}

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...