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 support@ccsinfo.com

How big maximum string arrays?

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







How big maximum string arrays?
PostPosted: Tue Mar 30, 2004 3:41 am     Reply with quote

Hi,
am using string array to save different languagges in my program.
Now i have a problem with the maximum size.

This works:
Code:
const char sprachemess[2][7][12]=
 {"Modus CH1","Modus CH1/2","PNP","NPN","Geschw:","Zeit:","Entf:",
  "Mode CH1" ,"Mode CH1/2" ,"PNP","NPN","Spd.:"  ,"Time:","Dis.:"};

This not:
Code:

const char sprachesetup[2][11][17]=
 {"Abstand Sensoren","Flankentrigger","Anzeigeeinheit","Messmodus"  ,"Trigger auf:","positive Flanke","negative Flanke","Anzeigeeinheit","Messmodus"  ,"Eine Messung","Endlos Messung",                             
  "Distance"        ,"Pulse"         ,"Speed Unit"    ,"Measurement","Trigger:"    ,"pos. Pulse"     ,"neg. Pulse"     ,"Speed Unit"    ,"Measurement","Single"      ,"Continue"};                                 

It occurs an error: Subscript out of range.
Has anybody i idea what i can do, apart from making the arrays smaller?
How big is the maximum size for string arrays?

Best regards
Patrick Frank
random_person
Guest







PostPosted: Tue Mar 30, 2004 4:28 am     Reply with quote

the maximum size for a char array will depend on the device you're using, and how much ram you have left to use in your program.

I don't think arrays can reach across banks. According to the CCSc.hlp file
Quote:
Subscript out of range
A subscript to a RAM array must be at least 1 and not more than 128 elements. Note that large arrays might not fit in a bank. ROM arrays may not occupy more than 256 locations..


So your array of characters is probably too bigfor the device/compiler to fit in one bank. I'm guessing that each character would occupy one "location"...or general purpose register of the PIC.

If using strings like that are absolutely necessary, you'll probably need external ROM to hold the data. If you are interfacing with a PC via something like RS232, consider holding the string arrays on the PC and an index system on the PIC. but i'm really not sure thats the nature of your project.

i hope that was somewhat helpful.
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Tue Mar 30, 2004 4:36 am     Reply with quote

Since you are using the keyword const your array will be placed in ROM. So the limit will be 256 locations and the RAM bank limit doesn't apply here. Try to break your array into two smaller ones.
random_person
Guest







PostPosted: Tue Mar 30, 2004 5:20 am     Reply with quote

Haplo is absolutely right. I didn't notice nor realize the arrays were consts and they are put in ROM. CSS-C treats dynamic indexing of these array as a simple table lookup function in assembly. You would thus be limited to a page (256) of elements for such an array within CSS-C confines.

so forget what I said previously. Smile
Patrick Frank
Guest







PostPosted: Tue Mar 30, 2004 5:46 am     Reply with quote

Hello,
thanks for the response.
I am using a PIC 16F876 and these Strings are for a Language Selection at the 4*16 LCD.

Ok, then i break the Arrays down into smaller ones.

Thanks
Patrick
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