Keil Logo

C166: Locate Constants To Absolute Addresses


Information in this article applies to:

  • C166 Version 6, or higher

QUESTION

I need to locate a memory range table to a specific memory address. In addition, I need at the beginning of this memory area a pointer to the address table, and a specified long value.

All this information must reside in Flash ROM on a fixed memory address (0x200 in my case).

How can I do this?

ANSWER

The following example locates certain variables in the order you specify in the source file. We have called this file INIT.C, and this module contains only the declaration for these variables.

#pragma ORDER     // keep variables in order

struct range  {
  unsigned long start;
  unsigned long stop;
};

extern const struct range   huge ranges[];

const struct range  huge * const huge rstart  = ranges;
const unsigned long         huge someval = 0x12345678;

const struct range          huge ranges[] =
{
  { 0,      0x25F  },
  { 0x260,  0x5000 },
  { 0,      0      },
};

The C166 Compiler generates an object file for INIT.C and includes a section for all the variables in the huge const memory area.

To locate this section, enter under Options for Target - L166 Locate - Users Sections:

?HC?INIT%HCONST (0x200)

The L166 SECTIONS directive requires that you enter both the section name and the memory class name.

MORE INFORMATION

SEE ALSO


Last Reviewed: Thursday, February 25, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.