Placing a pointer table at a specific address
Technical Note 44835
Architectures:
All
Component:
compiler
Updated:
11/6/2015 12:31 PM
Introduction
This Technical Note discusses how to place an array of pointers at a specific address.
Solution
In an IAR C/C++ Compiler version, which supports @ placement, there are two methods to use. Either declare the array as const or if values needs to be change at run-time declare the array as non-initialized.
The first method can look like
unsigned char * const RamAddresses[4] @ 0x8000 =
{
&object1,
&object2,
&object3,
&object4,
};
Second method
This method needs two actions.
The absolute placement (@ symbol) does not allow initialized non-const variables. So declare the array as __no_init.
__no_init unsigned char * RamAddresses[4] @ 0x8000;
Then in application code initialize the array, for example at the beginning of main().
RamAddresses[0] = &object1;
RamAddresses[1] = &object2;
RamAddresses[2] = &object3;
RamAddresses[3] = &object4;
All product names are trademarks or registered trademarks of their respective owners.