Address of variables

For general Flowcode discussion that does not belong in the other sections.
Post Reply
Osta
Posts: 53
http://meble-kuchenne.info.pl
Joined: Thu Dec 10, 2020 1:12 pm
Has thanked: 1 time
Been thanked: 3 times

Address of variables

Post by Osta »

Hey!
Tell me how to find out the address of the declared variables?
Thanks!

mnfisher
Valued Contributor
Posts: 938
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 502 times

Re: Address of variables

Post by mnfisher »

Hi Osta,

You need to use a little bit of C. Since FC doesn't have an address type - use an int large enough to hold the address (so 16bit or 32 bit)

In a C block

Code: Select all

FCL_ADDR = &FCV_VARNAME;
Where addr is defined as a local variable - and varname a global - note that FC capitalises the variable name and adds FCL (local) or FCV (global).

Note that to read or write to the address you'll also need to use some C:

Martin

Osta
Posts: 53
Joined: Thu Dec 10, 2020 1:12 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Address of variables

Post by Osta »

Thanks Martin!
Got it.
Regards Osta.

medelec35
Matrix Staff
Posts: 1432
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 506 times
Been thanked: 469 times

Re: Address of variables

Post by medelec35 »

There is an alternative method.
When you compile there are various files created.
For PIC if you look in the .sym file and search (using ctrl F) for your variable, the stored address is shown in hex
The format is _FCV_YOURVARIABLE (for global) or _FCL_YOURVARIABLE (For local).
Stored address.png
Stored address.png (11.9 KiB) Viewed 1975 times
Depending on the side of the variable using more than one address could be used.
Both the above are bytes so only one location each is used.
with integers, it will be two, etc.
I'm not sure about AVR.
Martin

Osta
Posts: 53
Joined: Thu Dec 10, 2020 1:12 pm
Has thanked: 1 time
Been thanked: 3 times

Re: Address of variables

Post by Osta »

Thank you so much!!!!

Post Reply