Maximum String Length for 16 and 32-bit PICs

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 8.

Moderator: Benj

Post Reply
Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Maximum String Length for 16 and 32-bit PICs

Post by Brendan »

Hello all.

I've seen something in an old FC7 forum topic to suggest that max string length for 16-bit (and possibly 32-bit) PICs was increased, from 8-bit to 'something' to accommodate 400 chars in a former 16-bit PIC project. However, the help Wiki continues to suggest 256 chars max...

https://www.matrixtsl.com/wiki/index.ph ... able_Types

I'm presently coding a 32-bit PIC and it will be a few days yet before I have hardware to play with, so just trying to establish the maximum string length in FC8 when declaring them - e.g. ThisString[??]. Experimentally, I can declare ThisString[100000] in the applicable FC8 project and the hex file builds without complaint, though I'm not so sure I can rely on that. In reality, I need to store about 20k chars streamed over UART.

Many thanks,
Brendan

mnf
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Maximum String Length for 16 and 32-bit PICs

Post by mnf »

Hi Brendan,

Have a look at the c generated - if there is a

Code: Select all

X = str_len(str)
type statement or an index

Code: Select all

while (str[X])...
then the max length will be determined by the size of this and other variables if x is 8 bit then 255 characters is probably your lot.

It would be easy to write a new routine using the individual character send to send data up to max in string length... Using a 32 bit index would allow any number of characters (2^32-1!) and probably overkill for most applications

Martin

mnf
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Maximum String Length for 16 and 32-bit PICs

Post by mnf »

Are you actually sending a string or an array of data?

- in a string 0 marks the end of string. If it was an array of data then 0 might be a valid value - and you would typically also pass a length to.

Martin

mnf
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Maximum String Length for 16 and 32-bit PICs

Post by mnf »

Looking at the code generated...

Code: Select all

void FCD_05481_cal_uart__SendString(MX_CHAR *FCL_DATA, MX_UINT16 FCLsz_DATA)
{
    //Local variable definitions
    MX_UINT8 FCL_IDX;
    MX_UINT8 FCL_LEN;
So - in FC8 at least you will be limited to a maximum of 255 characters if you use SendString. Note this seems to be fixed in v9 with a 16bit string length....

Martin

mnf
Valued Contributor
Valued Contributor
Posts: 1189
Joined: Wed May 31, 2017 11:57 am
Has thanked: 70 times
Been thanked: 439 times
Contact:

Re: Maximum String Length for 16 and 32-bit PICs

Post by mnf »

Something like:
senddata.JPG
senddata.JPG (12.3 KiB) Viewed 5050 times
Where data (an array - you can use any value in the parameter definition, data[2] for example - and then pass any size array (data[10000]).

Also pass the length - as mentioned this will allow data arrays (including 0) - if you want to use strings (0 is termination character) and not pass a length.

use something like:
senddata2.JPG
senddata2.JPG (15.63 KiB) Viewed 5050 times
Martin

Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Re: Maximum String Length for 16 and 32-bit PICs

Post by Brendan »

Hi Martin.

My apologies for the delayed reply, and thank you for the detailed information you provide.

I've noted your comment regarding 8-bit string length limitation in FC8 and 16-bit in FC9 (thank you). From an initial forum search my question mainly arose from this thread regarding FC7: https://www.matrixtsl.com/mmforums/view ... 63&t=19000 implying longer strings passed into a modified UART component.

My reason for processing strings instead of simple Byte arrays is due to a project that has grown somewhat (fundamentally based around strings) and ported to 32-bit micro, so I needed to establish prevailing string length limitation in FC8. I do have FC9 but only a single license presently, so trying to work within the bounds of FC8 for the present collaborated project.

Once again, very many thanks for your time to reply and accompanying information.

Best regards,
Brendan

Post Reply