8 years, 8 months ago.

Is UART printf possible through SWD/JTAG?

Hi there, I use the JTAG/SWD port on my nrf51-DK board to program external boards. This is working fine but I can't printf debug messages to a terminal connected to the DK's virtual comm port. The nordic user guide says "The UART signals are routed directly to the Interface MCU." Does this mean I can't printf debug messages from my external board as obviously there's no connection between the external board's UART and the Interface MCU? What else could I do to simply print out debug messages on my notebooks terminal? Is there something like a printf for SWD?

Thanks! Jens

1 Answer

8 years, 8 months ago.

There is a simple serial connection as part of the SWD interface. This requires that the SWO (single wire output) is connected and supported by the target platform and by the SWD interface. However, the nordic is an M0 core and they dont support SWO. Not sure about the SWD interface on the nordic board. SWO may also not be implemented. The nucleo board do support SWO. You can take a look at my example on how to use SWO for those platforms that support this feature.

The alternatives in your case are:

-disconnect the UART between the target and the interface on your programmer board and connect a serial port on your external board. Or

-use an external FTDI 232 or similar serial to UART converter to connect your external board to the host PC. This hardware is available on ebay etc.

Accepted Answer

Thanks Wim for your swift reply!!! Good idea, I have a FTDI 232 lying around. Working fine for me. Probably I could use the DK's UART to USB bridge as well. Thanks again, Jens

Update: I flashed the NRF-DK with the program below to avoid the FTDI.

#include "mbed.h"              
 
Serial pc(USBTX, USBRX);
 
int main() {
    while(1) {
        pc.putc(pc.getc());
    }
}

/media/uploads/jensstruemper/img_20150828_165548.jpg

posted by Jens Strümper 28 Aug 2015

This looks like the first alternative that I proposed: use the programmer part as serial to USB interface. However, you should probably disconnect the target nrf on the board from the programmer part. Note that unless there is some protection provided on the board (eg series resistors or disconnect jumpers) you have now short circuited the TX output of the programmer (going to the RX of the target nfr) with the TX output coming from your external board (blue wire). Your application code above will just receive the data from both sources on its RX input and echo it out on its TX to the programmers RX input. The short may damage the serial port on the programmer part and on your external processor.

posted by Wim Huiskamp 28 Aug 2015