<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Ways of logging data while debugging</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/84788/ways-of-logging-data-while-debugging</link><description>Hi guys, I am fairly new to nRF and I try to understand the ways that data can be displayed to the terminal emulator. 
 So far, I have noticed that there are four different ways(!!!) to do so. Please correct me if I am wrong 1. Printf() function 
 2.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 16 Feb 2022 14:22:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/84788/ways-of-logging-data-while-debugging" /><item><title>RE: Ways of logging data while debugging</title><link>https://devzone.nordicsemi.com/thread/353399?ContentTypeID=1</link><pubDate>Wed, 16 Feb 2022 14:22:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b720c6e-3770-4488-834b-3687ee675a0b</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>[quote user="Giovani_Giorgio"]So, if I understand correctly, the NRF_LOG library is the frontend that I use in my app code and backend RTT or UART are the ways that the nRF52840 exchanges data with the debugger uController and from there to the DK USB that is connected to the debugger(?) .[/quote]
&lt;p&gt;Yes, that is correct!&lt;/p&gt;
[quote user="Giovani_Giorgio"]Also, if I want to use the nRF uart for communication with another external peripheral like a GPS module I can disable the UART backend and enable only the RTT backend ?[/quote]
&lt;p&gt;Yes, that is one alternative. Another alternative (given that you are using nRF52840 or nRF52833) is to use the &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/uarte.html#topic"&gt;second UARTE instance&lt;/a&gt; (UARTE1) to communicate with the external device, through libUARTE/UART driver/app_uart, and keep the logging enabled over UARTE0 instance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ways of logging data while debugging</title><link>https://devzone.nordicsemi.com/thread/353335?ContentTypeID=1</link><pubDate>Wed, 16 Feb 2022 11:59:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa49c73e-ec68-4bd9-a991-547a1c088617</guid><dc:creator>Giovani_Giorgio</dc:creator><description>&lt;p&gt;Hi, thank you for the detailed answer. &lt;/p&gt;
[quote userid="14926" url="~/f/nordic-q-a/84788/ways-of-logging-data-while-debugging/353307#353307"]Many of our libraries are written with a frontend/backend architecture. Where the frontend interfaces with the application code with a static API, multiple backends can be configured and enabled to process the requests from the frontend. In the NRF_LOG library, different backends are supported as physical transport layers between the chip and the receiver terminal.[/quote]
&lt;p&gt;So, if I understand correctly, the NRF_LOG library is the frontend that I use in my app code and backend RTT or UART are the ways that the nRF52840 exchanges data with the debugger uController and from there to the DK USB that is connected to the debugger(?) .&lt;/p&gt;
&lt;p&gt;Also, if I want to use the nRF uart for communication with another external peripheral like a GPS module I can disable the UART backend and enable only the RTT backend ? &lt;br /&gt;&lt;br /&gt;Very helpful answer indeed!!!&lt;br /&gt;Thank you so much!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ways of logging data while debugging</title><link>https://devzone.nordicsemi.com/thread/353307?ContentTypeID=1</link><pubDate>Wed, 16 Feb 2022 09:48:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d230d95-cb5f-43ca-9ba4-c0db7d2ee05b</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]&lt;p&gt;So far, I have noticed that there are four different ways(!!!) to do so. Please correct me if I am wrong&lt;br /&gt;&lt;br /&gt;1. Printf()&amp;nbsp; function&lt;/p&gt;
&lt;p&gt;2. NRF_LOG_INFO() function with RTT backend&lt;/p&gt;
&lt;p&gt;3. NRF_LOG_INFO() function with UART backend&lt;/p&gt;
&lt;p&gt;4. RTT communication&lt;/p&gt;[/quote]
&lt;p&gt;There is a lot more alternatives, but I can&amp;#39;t list all here (some alternatives are &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/lib_usbd_class_cdc.html"&gt;USB CDC ACM&lt;/a&gt;, &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/lib_cli.html"&gt;NRF_CLI&lt;/a&gt;, &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/group__nrf__uart.html"&gt;UART driver&lt;/a&gt;/&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/group__app__uart.html"&gt;library&lt;/a&gt;/&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/lib_libuarte.html"&gt;libUARTE&lt;/a&gt;, etc). The number of methods all comes down to the desired API abstraction level&amp;nbsp;or low-level access to&amp;nbsp;HW layers. There is no difference in the physical way data are transferred between the chip and the terminal when using alternative 1/3 or 2/4, it is just different levels of abstraction between the HW and the application.&amp;nbsp;For logging, NRF_LOG is the preferred library for passing log strings from the chip to a terminal. It supports different backends, log levels, deferred log processing, along with other features you can read more about in the documentation.&lt;/p&gt;
[quote user=""]First of all what RTT or UART &lt;strong&gt;backend&lt;/strong&gt; means?[/quote]
&lt;p&gt;Many of our libraries are written with a frontend/backend architecture. Where the frontend interfaces with the application code with a static API, multiple backends can be configured and enabled to process the requests from the frontend. In the NRF_LOG library, different backends are supported as physical transport layers between the chip and the receiver terminal.&lt;/p&gt;
[quote user=""]Also, how are those configurations selected /activated and where do I see the data if use each one[/quote]
&lt;p&gt;1. printf() is a standard C function for formatting strings and pass this to stdout. In nRF5 SDK, there is a &lt;a title="Retarget layer for stdio functions" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/group__retarget.html?cp=8_1_6_10_66"&gt;Retarget layer for stdio functions&lt;/a&gt;&amp;nbsp;which overrides the default stdio target and pass the strings over UART (through app_uart library). This requires app_uart to be initialized first. See&amp;nbsp;&lt;a title="UART Example" href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/uart_example.html?cp=8_1_4_6_48"&gt;UART Example&lt;/a&gt;&amp;nbsp;how this is enabled/configured/used in an application.&lt;/p&gt;
&lt;p&gt;2. The RTT backend for NRF_LOG can be enabled by setting the sdk_config.h symbol&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/group__nrf__log__backend__rtt__config.html#gad5ead51bfb953f3a3bb8199665affa8d"&gt;NRF_LOG_BACKEND_RTT_ENABLED&lt;/a&gt;. If the required source files and headers are included, and NRF_LOG_ENABLED is set in your sdk_config.h file, you can initialize the logger and backend in code using the following macros:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;APP_ERROR_CHECK(NRF_LOG_INIT(NULL));
NRF_LOG_DEFAULT_BACKENDS_INIT();&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;3. Same as above, but with&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/group__nrf__log__backend__uart__config.html#gafb29ccb5684e4406e96009667cd036c7"&gt;NRF_LOG_BACKEND_UART_ENABLED&lt;/a&gt;&amp;nbsp;symbol.&lt;/p&gt;
&lt;p&gt;4. See &lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/debugging-with-real-time-terminal"&gt;this blog post&lt;/a&gt;. The Segger RTT source files can be found in&amp;nbsp;nRF5_SDK_17.1.0_ddde560\external\segger_rtt.&lt;/p&gt;
[quote user=""]I understand that the nRF52840 on the DK communicates with the onboard debugger uC through UART and from there the debugger communicates with the PC through USB port. Correct?[/quote]
&lt;p&gt;Yes, correct. See&amp;nbsp;&lt;a title="Virtual COM port" href="https://infocenter.nordicsemi.com/topic/ug_nrf52840_dk/UG/dk/vir_com_port.html?cp=4_0_4_6_1"&gt;Virtual COM port&lt;/a&gt;.&lt;/p&gt;
[quote user=""]I also understand that the nRF52840 is programmed via jlink through the debugger uC but I don&amp;#39;t understand&amp;nbsp; how all those protocols are used and when with respect to the previous 4 ways of displaying data during debugging[/quote]
&lt;p&gt;RTT works over the &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/dif.html#dap"&gt;SWD interface&lt;/a&gt;, which is the same interface used for programming the chip. The interface MCU on the DK runs a firmware that supports send and receive data over SWD, sending and receiving data over USB from a computer, and sending/receiving UART data from the nRF5x chip.&lt;/p&gt;
[quote user=""]Since I am really confused&amp;nbsp; could someone give a simple explanation of how these things work or is there any fundamental guide including all these variations?[/quote]
&lt;p&gt;Hope my answers help clear up your confusions!&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>