| |||||
Technical Support Support Resources
Product Information | ARM: LOCATING VARIABLES AT ABSOLUTE MEMORY ADDRESSESInformation in this article applies to:
QUESTIONI need to locate a variable at a fixed memory address. How can I do this using C source code? ANSWERWith the GNU GCC Compiler you may use only pointer definitions to access absolute memory locations. For example: /* General Purpose Input/Output (GPIO) */ #define IOPIN0 (*((volatile unsigned long *) 0xE0028000)) . . . IOPIN0 = 0x4; With the RealView ARM C Compiler, you may use either pointer definitions (as shown above) or __attribute__((at(address))) keyword to define a variable at a fixed memory address. In contrast to the pointer construct, the following definition also makes a correct memory reservation, so that the area cannot be used twice. int var __attribute__((at(0x40001000))); . . . var = 4; // changes the memory location at 0x40001000 With the Keil CARM C Compiler, you may use either pointer definitions (as shown above) or _at_ keyword to define a variable at a fixed memory address. As with the RealView C Compiler, the following definition also makes a correct memory reservation, so that the area cannot be used twice. int var _at_ 0x40001000; . . . var = 4; // changes the memory location at 0x40001000 MORE INFORMATION
Last Reviewed: Wednesday, January 09, 2008 | ||||
| |||||