This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52840DK Logging to UARTE1

Hello,

Using libuarte I have been able to set up UARTE0 and UARTE1 for main communications, and debug communications respectively. While using UARTE1 to print out debug messages from my own code is nice, I quickly realized that this isn't really what I needed as the NRF_LOG_... calls would not be going to UARTE1. I know it is possible to set the logging backend to RTT, or UART, but I don't really see any way in sdk_config to use UARTE0/1 as a logging backend.

I am mainly concerned with how to debug a custom board which does not have the USB port used for RTT debugging. If it is not possible to log to UARTE1 while allowing the other UARTE0 to function, how would RTT work on a custom board? Is it possible to use RTT on the nRF52840DK without connecting to the USB port, if so which pins would I need to connect an FTDI cable to in order to see the output?

  • Hi 

    What about using UARTE1 for your main communication instead, and UARTE0 for debugging?

    Hardware wise both of these interfaces are identical. 

    As for connecting RTT on a custom board what you need to do is to expose the SWD debugging interface, namely the SWDIO and SWDCLK pins. By connecting an nRF52840DK to these pins you can program, debug and receive RTT logs from the target. 

    Best regards
    Torbjørn

  • Interesting, would setting the logging backend to UART automatically redirect the output to UARTE0 by default if UARTE is being used?

    Is it possible to do RTT and SWD debugging with two nRF52840DK's? I do not have a custom board yet as I am still trying to work things out with the dev kits before moving forward.

    I tried to follow the wiring shown in this thread, but am not able to debug/program the dev kit which is acting as the custom board. When I try to start RTT, I receive the "could not connect to target" error, with the following log details.

    LOG: J-Link RTT Viewer V6.82b: Logging started.
    LOG: Terminal 0 added.
    LOG: Connecting to J-Link via USB...
    LOG: Device "NRF52840_XXAA" selected.
    LOG: InitTarget() start
    LOG: InitTarget() end
    LOG: InitTarget() start
    LOG: InitTarget() end
    ERROR: Could not connect to target device.

    Here is the wiring between the two dev kits:

    I can see that the dev kit acting as the custom board is on when powering up the main board over USB.

  • Hi 

    flonch said:
    nteresting, would setting the logging backend to UART automatically redirect the output to UARTE0 by default if UARTE is being used?

    Yes. Most of the devices in the nRF52 family only have one UARTE interface (UARTE0), so this is the one that the log interface is setup to use. 

    flonch said:
    Is it possible to do RTT and SWD debugging with two nRF52840DK's? I do not have a custom board yet as I am still trying to work things out with the dev kits before moving forward.

    This is possible, yes. 

    The easiest way to do it is to get one of the 10-pin SWD cables, and connect the debug out port (P19) on one kit to the debug in port (P18) on another.  

    This cable can be found many places, including on Adafruit.

    flonch said:
    I tried to follow the wiring shown in this thread, but am not able to debug/program the dev kit which is acting as the custom board. When I try to start RTT, I receive the "could not connect to target" error, with the following log details.

    I assume this doesn't work because P20 is designed for debug out only, not debug in, but I will have to double check this with one of my colleagues and get back to you. 

    Best regards
    Torbjørn

  • Thanks for the information. I originally was looking to have debugging over UART, but RTT seems more favorable now seeing as it would be the same process as programming the custom board more or less.

    I won't be able to test P18 for a few days until the cable arrives, but your answer does make sense if P20 is output only.

  • Hi 

    RTT is convenient in that it doesn't require any hardware peripherals other than the debugger, and adds quite little impact to the code run time. 

    Unless you have more questions I will consider the case closed then Slight smile

    Best regards
    Torbjørn

Related