View previous topic :: View next topic |
Author |
Message |
sergioigel
Joined: 13 Aug 2010 Posts: 26 Location: RJ/Brazil
|
String too long |
Posted: Fri Aug 25, 2017 8:25 am |
|
|
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: 19553
|
|
Posted: Fri Aug 25, 2017 8:41 am |
|
|
What processor?. |
|
|
sergioigel
Joined: 13 Aug 2010 Posts: 26 Location: RJ/Brazil
|
|
Posted: Fri Aug 25, 2017 9:09 am |
|
|
Ttelmah wrote: | What processor?. |
PIC16F18877
CCS PCM Compiler v5.074 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19553
|
|
Posted: Fri Aug 25, 2017 12:03 pm |
|
|
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
|
|
Posted: Fri Aug 25, 2017 12:57 pm |
|
|
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: 19553
|
|
Posted: Fri Aug 25, 2017 2:24 pm |
|
|
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. |
|
|
|