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

UART debug logging

Hello,

I know that this question has been asked a few times, but I am a little desperate after trying to get debug logging over the Virtual COM Port to work. Here are the steps that I did:

  • I got myself a nRF51 USB Dongle (pca10031 board with nRF51422_xxAC chipset)
  • I configured a new Project in Keil with all the necessarey libraries and a 120 Soft Device
  • I wrote a main.c that toggles the onboard LED in an infinite loop and calls printf after each loop.
  • I called app_trace_init() at the beginning to set up the debug UART connection

From looking at the app_trace_init function I gathered, that the Baud rate is 115200, as opposed to the Baud rate stated in the documentation (38400). I think that flow control is hardware? (UART_FLOW_CONTROL_ENABLED).

I configured Putty to use 8 data bits, 1 stop bit, and varied all other parameters but to no avail. I can only get garbage characters, but at least the length seems to be similar to the string that I am trying to trace.

Could you please point me in the right direction?

Thanks, Marius Heil

  • Looks like app_trace_init() sets the baud rate to 115200 by default. But notice the #ifdef ENABLE_DEBUG_LOG_SUPPORT in this file. You should define this under the "C/C++" fan in options.

    I could get it to work with the ble_app_hrs_c_s120_pca10031 example. My settings were:

    • Putty
    • 115200
    • 8 data bits
    • 1 stop bit
    • No parity
    • xon/xoff flow control

    Did you try with an example without modifying it? Which SDK are you using?

  • Hello,

    thanks a lot. I managed to get UART working by building upon the simple_uart driver. I had a modified example, maybe that was the Problem. I managed to get another sample working by using 19200 baud rate and most of the time, RTS/CTS works for me. Most of the time, it boils down to searching in the code for the places where the UART interface is started. I am only starting the development and I have a hard time finding the right documentation. Most of the time it's somewhere, but I cannot find it :-)

  • As I want to debug using Hyperterminal But always got garbage values...... I also tried 9600 Baud rate and it executed few values well than after again started with garbage values. PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPppppppppppppp1PPPPPPPPPPPPPPPPPPPPPPPPPPPPPP PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP this is something.

  • hi,stian:

    when i test uart simple example, all is OK.. but when i test using app_trace_init() and app_trace_log(), i has the same question.. I can only get garbage characters...

    int main(void) {

    app_trace_init();

    while (1) {

    app_trace_log("a==B++\r\n"); }

    }

    but the log messages are: +B=aaB==a+==a

    configuration: pca10028, APP_UART_FLOW_CONTROL_DISABLE, 38400, image description

    and I change to use app_uart_fifo.c for app_uart. and test again, the following is the result:

    the log messages are:

    Ba+=+= image description

  • hi, all: the code of SDK9.0, simple uart example and app_trace_init/ app_trace_log are the same after i check the code. why i get error message log, please add some time delay in the loop. ererything is OK. ..

Related