View previous topic :: View next topic |
Author |
Message |
VV Guest
|
Data item too big |
Posted: Tue Feb 23, 2010 1:06 pm |
|
|
Hi
I would like a little advice from anyone out there.
I try to store data in an array data[32][20] in 16F877A. But when I compile it, the error says 'data item too big'. I checked the datasheet of 16F877A and found out the RAM size is 368 bytes. Does it mean 32*20 is much bigger than 368 bytes so that this 2-dimensional array cannot be created?
Thank you. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
VV Guest
|
|
Posted: Tue Feb 23, 2010 1:44 pm |
|
|
Thank you.
I have already read that and found out only 'data[32][3]' works since 32*3=96. It only occupies 20% of ram. When I tried data[32][4], it says 'not enough RAM for variables'.
I also followed your suggestion on the other post to adjust '#device=*16', but there is no change, there still has no enough ram for variables.
So how to enlarge the ram size?
Thank you[/quote] |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Feb 23, 2010 2:00 pm |
|
|
Quote: |
When I tried data[32][4], it says 'not enough RAM for variables'.
|
You didn't get the point from that post. 32 x 4 = 128 bytes.
That exceeds the size of one RAM bank. You can't do that in CCS.
The entire array must be contained within one RAM bank. You could
make several different arrays, as shown in the program below.
Each one fits in a different RAM bank. I've set them to the maximum
size allowed by the compiler (this was determined by testing).
If you want to make large arrays, then you need to move to the
18F-series PICs. Use a PIC such as the 18F4520. Then you won't
have these problems.
Code: |
#include <16F877.H>
#device *=16
#fuses XT, NOWDT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
int8 data1[96];
int8 data2[94];
int8 data3[86];
int8 data4[80];
//======================================
void main()
{
while(1);
} |
|
|
|
|