How to printf() to PC through J-Link?

来源:百度文库 编辑:神马文学网 时间:2024/05/04 10:00:26
if you are using a Cortex-M3 device and CMSIS, you can easily use the ITM_Sendchar(c) function, defined in CMSIS core_cm3.h.
The ITM output (channel 0 for printf) is captured from the J-Link through SWO sampling, this must be configured (dependant on your IDE).

On ARM7/9 there is a method called semihosting, a printf is redirected through armlib to the debugger, how this works with J-Link the Segger guys should be able to help :-)
In Keil uVision on ARM7/9 and there is the Real Time Agent doing this work, and the CMSIS for Cortex. Note, for STM32F10x the stm32f10x_dbg.ini (found i.e. in STLibBlinky) must be added to debug settings. In uVision you can watch the serial output when debugging in the RTA or ITM window under Serial Windows.

In IAR the printf's are captured through semihosting and sent to the Terminal. On CM3 the semihosting can also be used, or printf through ITM.

The advantage on ITM is, that the core does not need to be "stopped" when printing a message.