Placing strings

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
2,325件の閲覧回数
Teckna
Contributor V

Hi everyone,

 

I'm using CW 10.2, MQX 3.8.1 and Kinetis K60.

Due to an alomst full RAM use, I'm doing some optimization in my code.

I noticed that the instruction:

printf( "String to print\n");

Is compiled putting the pointer to the string in the register and then calling the printf function: the pointer points to an address placed in RAM that is initialized in the startup phase by copying data from the flash to the RAM.

I would like to put the string "String to printf\n" only in flash the way the copying phase is not needed and the RAM location can be used in another way.

 

How must I specify this requirement in CW?

 

Many thanks

Teckna

ラベル(1)
タグ(4)
0 件の賞賛
返信
1 解決策
1,778件の閲覧回数
BlackNight
NXP Employee
NXP Employee

Hello,

there is a compiler option you have to set for putting strings into .rodata:

2837_2837.png

Hope this helps,

Erich

元の投稿で解決策を見る

0 件の賞賛
返信
5 返答(返信)
1,778件の閲覧回数
Monica
Senior Contributor III

Hey there Teckna!

Has this helped you out?

We would like to know how is your project going!

Regards!

0 件の賞賛
返信
1,778件の閲覧回数
Teckna
Contributor V

Hi Monica,

At Erich suggestion, I saved a lot of RAM.

Many thanks

Teckna

0 件の賞賛
返信
1,779件の閲覧回数
BlackNight
NXP Employee
NXP Employee

Hello,

there is a compiler option you have to set for putting strings into .rodata:

2837_2837.png

Hope this helps,

Erich

0 件の賞賛
返信
1,778件の閲覧回数
Teckna
Contributor V

No one can help?

Teckna

0 件の賞賛
返信
1,778件の閲覧回数
CrasyCat
Specialist III

Hello

As far as I can tell the string constants are allocated in section .rodata.

Can you please check in your linker file, where this section is placed.

If it is placed in a block of memory located in RAM, you may just have to move it over into a block of memory located in flash

I hope this helps.

CrasyCat

0 件の賞賛
返信