KW41Z printf on startup file resets program

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

KW41Z printf on startup file resets program

ソリューションへジャンプ
915件の閲覧回数
satsok_n
Contributor III

I am trying to run some code in file startup_mkw41z4.c following this post https://mcuoneclipse.com/2019/02/17/debugging-the-startup-code-with-eclipse-and-gdb/.When I try to run some code in this file I manage to run first part and when I use printf it resets the program. If I remove printf the code runs normaly. Any suggestions? 

0 件の賞賛
1 解決策
897件の閲覧回数
ErichStyger
Senior Contributor V

a good way is to use SEGGER RTT (see https://mcuoneclipse.com/2015/07/07/using-segger-real-time-terminal-rtt-with-eclipse/) which is fast and you can easily export lots of data.

Another way is to export memory directly, see https://mcuoneclipse.com/2012/05/04/dump-my-device-memory/

Or if you want to do this for individual variables, you easily can do this with gdb and you can script it, see https://mcuoneclipse.com/2020/04/13/dumping-variables-and-arrays-with-gdb-in-eclipse/

 

I hope this helps,

Erich

元の投稿で解決策を見る

0 件の賞賛
5 返答(返信)
903件の閲覧回数
ErichStyger
Senior Contributor V

Hi @satsok_n ,

it really depends what you are using for the printf: UART? semihosting?

In both cases you will need to have the drivers behind it intialized and working. For example  you cannot access/use the UART if the peripheral is not clocked and pins are not muxed (done in main, not in the startup code).

If using semihosting you need to initialize the standard library (done at the end of the startup code).

So while you could use printf, it is really not good to use it, see https://mcuoneclipse.com/2013/04/19/why-i-dont-like-printf/ because it uses lots of stack space and memory.

I hope this helps,

Erich

0 件の賞賛
900件の閲覧回数
satsok_n
Contributor III

I used printf in order to export some variables to console and copy paste them in a text file. Can you suggest any other way to export data?

0 件の賞賛
898件の閲覧回数
ErichStyger
Senior Contributor V

a good way is to use SEGGER RTT (see https://mcuoneclipse.com/2015/07/07/using-segger-real-time-terminal-rtt-with-eclipse/) which is fast and you can easily export lots of data.

Another way is to export memory directly, see https://mcuoneclipse.com/2012/05/04/dump-my-device-memory/

Or if you want to do this for individual variables, you easily can do this with gdb and you can script it, see https://mcuoneclipse.com/2020/04/13/dumping-variables-and-arrays-with-gdb-in-eclipse/

 

I hope this helps,

Erich

0 件の賞賛
886件の閲覧回数
satsok_n
Contributor III

Thanks a lot. This has been very helpful. 

0 件の賞賛
910件の閲覧回数
nxf56274
NXP Employee
NXP Employee

Hi,

Before you use printf function, you should make sure you have initialized the uart. 

Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 件の賞賛