Using Pragma in MCUXpresso

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

Using Pragma in MCUXpresso

Jump to solution
4,098 Views
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},
...
};

Labels (1)
Tags (1)
1 Solution
3,855 Views
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

View solution in original post

0 Kudos
Reply
5 Replies
3,856 Views
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 Kudos
Reply
707 Views
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]
Tags (1)
0 Kudos
Reply
3,855 Views
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,855 Views
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 Kudos
Reply
3,855 Views
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 Kudos
Reply