CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Data item too big

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
VV
Guest







Data item too big
PostPosted: Tue Feb 23, 2010 1:06 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 23, 2010 1:08 pm     Reply with quote

See this thread. It explains the limitations on the maximum array size
with the 16F-series PICs:
http://www.ccsinfo.com/forum/viewtopic.php?t=27958
VV
Guest







PostPosted: Tue Feb 23, 2010 1:44 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Feb 23, 2010 2:00 pm     Reply with quote

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);
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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