Hey!
Tell me how to find out the address of the declared variables?
Thanks!
Address of variables
-
- Posts: 53
- http://meble-kuchenne.info.pl
- Joined: Thu Dec 10, 2020 1:12 pm
- Has thanked: 1 time
- Been thanked: 3 times
-
- Valued Contributor
- Posts: 1462
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 135 times
- Been thanked: 713 times
Re: Address of variables
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
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
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;
Note that to read or write to the address you'll also need to use some C:
Martin
-
- Matrix Staff
- Posts: 1920
- Joined: Wed Dec 02, 2020 11:07 pm
- Has thanked: 622 times
- Been thanked: 645 times
Re: Address of variables
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). 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.
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). 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