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

String too long

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



Joined: 13 Aug 2010
Posts: 26
Location: RJ/Brazil

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

String too long
PostPosted: Fri Aug 25, 2017 8:25 am     Reply with quote

Hi,
When I try to compile this code, it works:
Code:
char frame[90];
strcpy(frame,"123456789_123456789_123456789_123456789_123456789_123456789_123456789_123");

and if I use this code, it does not work:
Code:
char frame[90];
strcpy(frame,"123456789_123456789_123456789_123456789_123456789_123456789_123456789_1234");
functions.c:274:16: Error#6 String too long

Somebody help me.
Thank you,
sergio
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Fri Aug 25, 2017 8:41 am     Reply with quote

What processor?.
sergioigel



Joined: 13 Aug 2010
Posts: 26
Location: RJ/Brazil

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Fri Aug 25, 2017 9:09 am     Reply with quote

Ttelmah wrote:
What processor?.


PIC16F18877
CCS PCM Compiler v5.074
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Fri Aug 25, 2017 12:03 pm     Reply with quote

That chip has maximum ram banks of just 80 bytes each. It'll only complain when you actually start to use the RAM.....

Don't try to copy the string to RAM. Use it from ROM.

Declare the string you want as a const, and use
#device PASS_STRINGS=IN_RAM
Not sure it'll do what you want, but it ought to use a small buffer and allow your code to handle the ROM string as if it is in RAM.
Honestly if you want to actually handle single lumps of RAM this long, then it'd be far easier to switch to a PIC18...
sergioigel



Joined: 13 Aug 2010
Posts: 26
Location: RJ/Brazil

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Fri Aug 25, 2017 12:57 pm     Reply with quote

Ttelmah wrote:
That chip has maximum ram banks of just 80 bytes each. It'll only complain when you actually start to use the RAM.....

Don't try to copy the string to RAM. Use it from ROM.

Declare the string you want as a const, and use
#device PASS_STRINGS=IN_RAM
Not sure it'll do what you want, but it ought to use a small buffer and allow your code to handle the ROM string as if it is in RAM.
Honestly if you want to actually handle single lumps of RAM this long, then it'd be far easier to switch to a PIC18...


I need to use a variable 100 bytes..... do you have a example how make this with this PIC ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Fri Aug 25, 2017 2:24 pm     Reply with quote

It'll generate the array, and automatically handle page switching to it, but you can't write it as one 'lump' with strcpy.

Code:

   char frame[101];
  strcpy(frame,"123456789_123456789_123456789_123456789_123456789_");
   strcpy(frame+50,"123456789_123456789_123456789_123456789_123456789_");

I've made it 101 characters, to allow for the extra null terminator, but overwritten the one put in by the first transfer.
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