Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
5 years, 10 months ago.
Redirecting printf statements via JLink instead of the default USBTX pin?
printf statements in MBED-OS by default uses the USBTX pins, however the custom board we have doesn't use the USBTX and USBRX pins, however the board has JLink headers that we program the NRF52840. So I was wondering if there is a way to re-direct the printf o/p to use the JLink headers so this can be potentially viewed on JLinkRTTViewer application or any other means?
I am attaching the image of the schematic of the Debugger (JLink) that we have on our custom board.
Thanks, Yogesh
Question relating to:
2 Answers
5 years, 9 months ago.
Thanks Wim, for your suggestion and I had logged this issue on the mbed-os github issues and I just had to add this piece of code in main.cpp and I can view the printf statements with Seggers JLinkSWOViewer.exe.
SWO Printf debug
#include "mbed.h" #include "platform/mbed_retarget.h" #include "drivers/SerialWireOutput.h" namespace mbed { FileHandle *mbed_target_override_console(int) { static SerialWireOutput swo; return &swo; } }
Thanks, Ajay
5 years, 10 months ago.
The nRF52840 is an ARM Cortex M4, so it supports the Single Wire Output (SWO) that can be used for debug messages. Try my SWO Lib and you should be able to use printf like calls. Note that I have not tested this on the nRF52840 as I dont have one available.