Using Pragma in MCUXpresso

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

Using Pragma in MCUXpresso

跳至解决方案
4,100 次查看
m_giraldi
Contributor II

I'm wondering how to use Pragam on MCUXpresso IDE (MKE16Z64xxx4). How should I proceed? I need to put an array of values in Flash.

#pragma ...

  const float min_max [23] [2]
=
{
{3.1415, 2.54},
...
};

标签 (1)
标记 (1)
1 解答
3,857 次查看
BlackNight
NXP Employee
NXP Employee

What kind of attribute do you want to use?

The standard way to tell the compiler special ways for gcc is using __attribute__ (see Using the GNU Compiler Collection (GCC): Common Variable Attributes ).

I hope this helps,

Erich

在原帖中查看解决方案

0 项奖励
回复
5 回复数
3,858 次查看
BlackNight
NXP Employee
NXP Employee

What kind of attribute do you want to use?

The standard way to tell the compiler special ways for gcc is using __attribute__ (see Using the GNU Compiler Collection (GCC): Common Variable Attributes ).

I hope this helps,

Erich

0 项奖励
回复
709 次查看
zmm
Contributor I
I'm wondering how to use Pragma on VScode MCUXpresso。I need to put a piece of code into the specified section.But it was ignored by the compiler.
#pragma GCC push_options
#pragma GCC section text=".custom_code"
void func(void)
{}
.
.
.
#pragma GCC pop_options

warning:ignoring '#pragma GCC section' [-Wunknown-pragmas]
标记 (1)
0 项奖励
回复
3,857 次查看
converse
Senior Contributor V

Read the MCUXpresso Usr Guide. NXP provide macros to help you do this, as described in the chapter on Placing specific code/data items. (Chapter 18.13 in latest user guide).

3,857 次查看
m_giraldi
Contributor II

Erich,

Imagine the data below ( const unsigned char texto[4][128] ), if I declare this way, this data will be allocated in the SRAM, I do not want this to happen, I need this data to be allocated in Flash. In Codewarrior I used the pragma and this data was allocated in ROM.

// Codewarrior ========================================
#pragma CONST_SEG ROM
/ *  "in here I put all the const that I needed to be allocated in ROM"  * /
const unsigned char texto[4][128] = { .... };

#pragma CONST_SEG DEFAULT

//==================================================

How to allocate " const unsigned char texto[4][128] " in Flash and not in SRAM using MCUXpresso?

I'm using MKE16Z64VLF4

"data"

const unsigned char texto[4][128] = { {0xFF, 0xFF, ... }, {0xFF, 0xFF, ....}, {0xFF, 0xFF, ...}, {0xFF, 0xFF, ...} };

0 项奖励
回复
3,857 次查看
BlackNight
NXP Employee
NXP Employee

If you are using the default/standard SDK linker files, then all constant objects get placed in FLASH anyway, so you don't need any #pragma.

I hope this helps,

Erich

0 项奖励
回复