How do I declare an array in a different segment?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How do I declare an array in a different segment?

跳至解决方案
1,517 次查看
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.


标签 (1)
0 项奖励
回复
1 解答
958 次查看
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 项奖励
回复
2 回复数
958 次查看
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

959 次查看
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 项奖励
回复