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?
Solved! Go to Solution.
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
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
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?
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
Thanks a lot. This has been very helpful.
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.
-------------------------------------------------------------------------------