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

int32 array length problem

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







int32 array length problem
PostPosted: Mon Mar 30, 2009 5:28 am     Reply with quote

Hello,
I am working witha PIC16F627 and I have to declare a big 1-D int32 array, but I have the error:

*** Error 87 "Main.c" Line 22(21,22): Data item too big

Is there a way to declare a 1-D array of int32 without this problem?
Is there a #pragma or other setting to do in the compiler?
Code:
const int32 bigarray[120]={
0,
1,
2,
...
...
...
}

Thanks!

Sirio
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Mon Mar 30, 2009 5:42 am     Reply with quote

For that array the PIC would have to have 120x4 = 480 bytes of contiguous RAM. PIC RAM is paged and blocks that big are rare. Does your PIC have blocks that big? You may have to split it up into several smaller arrays or get a really big PIC.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Ttelmah
Guest







PostPosted: Mon Mar 30, 2009 7:24 am     Reply with quote

No PIC will have pages that large. To handle this, you would need to be using a 18 chip, which has linear memory addressing, without the page limitations. On the 16 chips, the maximum _possible_ in a page is 128 locations. In fact the chip you are using, only has a _total_ of 224bytes, so trying to fit an array that needs 480bytes, is a 'hiding to nothing'.....
Think small.
Remember you are dealing with a tiny embedded processor. Try to work out ways of avoiding needing so much data.Otherwise you need to switch to larger tools. It is a bit like asking 'Why can't I fit this 40 ton container in my Honda Civic'. Wrong tool for the job. You either need to move the contents in smaller pieces that will fit in the small vehicle, or get a truck....

Best Wishes
Guest








PostPosted: Mon Mar 30, 2009 4:03 pm     Reply with quote

SherpaDoug wrote:
For that array the PIC would have to have 120x4 = 480 bytes of contiguous RAM. PIC RAM is paged and blocks that big are rare. Does your PIC have blocks that big? You may have to split it up into several smaller arrays or get a really big PIC.


Hi SherpaDoug,
Why should I have 480 bytes of RAM contiguous ? why RAM ??? I need to store a table, nothing more, constant, in ROM...
Just a constant lookup table of 120 x 32 bit numbers ...
In ROM I have several Kb of space!

Ttelmah wrote:

Remember you are dealing with a tiny embedded processor. Try to work out ways of avoiding needing so much data.Otherwise you need to switch to larger tools. It is a bit like asking 'Why can't I fit this 40 ton container in my Honda Civic'. Wrong tool for the job. You either need to move the contents in smaller pieces that will fit in the small vehicle, or get a truck....


It's ok, I know that it's a tiny processor, I'm not asking an MP3 decoder C source for a 12C508 Wink ...
I'm asking the possibility to store a lookup table in ROM of 120 * 4 (32 bits) = 480 bytes of ROM ... Am I asking so much?
I can bring it also with a bicycle, don't understand why should I buy a truck....

What I have discovered is that there is a limitation to array length, not to the room it really use:

if I declare a structure
Code:
typedef struct myStruct{
 int32 Var1;
 int32 Var2;
 int32 Var3;
 int32 Var4;
} Struct32bytes;

and I declare a
Code:
const Struct32bytes VeryBigArray[64];

the compiler works ok, or if I declare
Code:
const int32 bigarray[64]={
0,
1,
2,
...
...
...
}

the compiler works ok, but if I declare
Code:
const int32 bigarray[65]={
0,
1,
...
}

or
Code:
const Struct32bytes VeryBigArray[65];

the compiler stops and raise an error.

In the first case I have 256 bytes used, but in the second case I have 1024 bytes used ...

This is a stange behavior, isn't it? At the first time, it's an Honda Civic, at the second time it's a truck...

Could it be an identity problem Question

Bye!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Mar 30, 2009 4:26 pm     Reply with quote

The PCM compiler has a size limit on const arrays:
http://www.ccsinfo.com/forum/viewtopic.php?t=36526

Basically, most or all of your complaints will go away if you change to
the PCH compiler and use 18F-series PICs.
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