|
|
View previous topic :: View next topic |
Author |
Message |
Angus_Thomson Guest
|
Large array in RAM |
Posted: Thu Mar 26, 2009 5:31 am |
|
|
Hi all,
I am trying to create a large array in RAM to store 120 16-bit numbers such that I can access them in the most efficient way (in terms of processor time). I am using a PIC16F876A with the PCM compiler. Simply declaring:
gives me the compiler error 'Data item too big'; I am a bit of a C/low-level-PIC novice so I'm guessing this is something to do with the data spanning a bank in RAM? Either way, could someone please suggest the best method for storing such an array or structure so that reading data from a particular element is done in an efficient manner?
On a similar note, I am a little cofused as to CCS' response to the following line:
which gives the error 'Not enough RAM for all variables'. However, declaring the following does not:
Code: | long events[30];
long events2[30]; |
Apologies for the probably obvious questions above, but I'm trying to find my feet with the nuances of C on a PIC!
Many thanks,
Angus |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Mar 26, 2009 6:18 am |
|
|
PIC16 in special has limited RAM and some restriction in memory layout additionally. According to the bank structure, an array can't be larger than 128 Bytes, which explains the first error message.
Furthermore, the usable RAM has to be interleaved with existing special function registers in four banks, which further restricts the available array size. With 16F877 it's 80 respectively 96 Bytes, which explains your second observation.
You may want to consult FIGURE 2-3: PIC16F876A/877A REGISTER FILE MAP in the datasheet and the CCS C generated *.sym file showing the actual memory layout of your design, to see if the compiler misses any available option. If not, you simply have to split your data accordingly. |
|
|
Angus_Thomson Guest
|
|
Posted: Thu Mar 26, 2009 7:23 am |
|
|
Many thanks for your help; looking at the SYM file makes things a lot clearer. I guess I'll simply split the array into 3 in the seperate banks.
Cheers!
Angus
FvM wrote: | PIC16 in special has limited RAM and some restriction in memory layout additionally. According to the bank structure, an array can't be larger than 128 Bytes, which explains the first error message.
Furthermore, the usable RAM has to be interleaved with existing special function registers in four banks, which further restricts the available array size. With 16F877 it's 80 respectively 96 Bytes, which explains your second observation.
You may want to consult FIGURE 2-3: PIC16F876A/877A REGISTER FILE MAP in the datasheet and the CCS C generated *.sym file showing the actual memory layout of your design, to see if the compiler misses any available option. If not, you simply have to split your data accordingly. |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|
|
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
|