How do I declare an array in a different segment?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I declare an array in a different segment?

Jump to solution
1,223 Views
dporada
Contributor III

In CodeWarrior, I did this:

 

#pragma define_section my_ram2 ".display" abs32 RW

__declspec(section "my_ram2") uint8 Display[511];

 

This does not work in KDS.  I get an error saying that Display is undeclared.

 

Please help.


Labels (1)
0 Kudos
1 Solution
664 Views
dereksnell
NXP Employee
NXP Employee

Hi Don,

If you’d like to see how the GCC build tools in KDS can do this, you can use KDS to create a new project, and use it as an example. The interrupt vector table is forced to a specific memory section. I created a project with Processor Expert for the K64, and in vectors.c, the line below forces the vector table array into the .vectortable memory section. You can also review the linker file *.ld added to the project to see how .vectortable is used in the linker file.

__attribute__ ((section (".vectortable"))) const tVectorTable __vect_table = { /* Interrupt vector table */

View solution in original post

0 Kudos
2 Replies
664 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Donald:

The response by colleague Derek Snell is correct, you need __attribute__ ((section (...) )), and modify the linker file as necessary.

There are some tutorials and code examples about this:

Defining Variables at Absolute Addresses with gcc | MCU on Eclipse

Relocating Code and Data Using the CW GCC Linker File for Kinetis

Re: Controlling data and function placement in memory

Re: Re: Syntax to allocate memory assignments to faster memory

Regards!

Jorge_Gonzalez

665 Views
dereksnell
NXP Employee
NXP Employee

Hi Don,

If you’d like to see how the GCC build tools in KDS can do this, you can use KDS to create a new project, and use it as an example. The interrupt vector table is forced to a specific memory section. I created a project with Processor Expert for the K64, and in vectors.c, the line below forces the vector table array into the .vectortable memory section. You can also review the linker file *.ld added to the project to see how .vectortable is used in the linker file.

__attribute__ ((section (".vectortable"))) const tVectorTable __vect_table = { /* Interrupt vector table */

0 Kudos