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

Use UART and RTT debug interface on the same time

Hi,

I had merge UART and RTT  program into the same code.

1. When I use C/C++ compile option "ESB_PRESENT NRF_LOG_USES_RTT=1" to compile my source code , then I can find debug message on "J-Link RTT Viwer", but the UART interface will be crash (Use printf to output some message to UART).

2. If I don't use compile option "ESB_PRESENT NRF_LOG_USES_RTT=1" to compiler code, then UART can work correctly but "J-link Viewer" can not output any thing.

Is it possible use UART and RTT debug interface on the same time?  How can I do this job?

Thank you,

Chianglin

Parents
  • Hey Ives,

    Concurrent UART and RTT logging is not supported. I can put in a request for such a feature, but I need to know your use case, why do you need to use both backends?

    Cheers,

    Håkon.

  • Hi Håkon,

    Thank you for your answer.

    My use case is:

    1. Use UART to communicate between nRF51822 and Host (ex: Raspberry PI)

    2. Use RTT to print debug message.

    Can I use these two interface in the same source code?

    Thank you,

    Chianglin

  • Oh, the UART should be free to use if you all logging is sendt over RTT.

    My first guess is that the logging module has UART defined as a backend.

    My second guess is that the UART driver is not initialized.

    My third guess is that there is something from with how printf is used in retarget.c.

    Can you check out these guesses and give me some more information, like returned error codes and source code?

  • Hi Hookonsh,

    I am using SDK 11.0.0 code base to do my job.

    Following is my source code:

    int main(void)
    {
    ret_code_t err_code;

    err_code = NRF_LOG_INIT();
    APP_ERROR_CHECK(err_code);

    clocks_start();

    err_code = esb_init();
    APP_ERROR_CHECK(err_code);

    LEDS_CONFIGURE(LEDS_MASK);
    LEDS_OFF(LEDS_MASK);

    const app_uart_comm_params_t comm_params =
    {
    19,
    18,
    RTS_PIN_NUMBER,
    CTS_PIN_NUMBER,
    APP_UART_FLOW_CONTROL_DISABLED,
    false,
    UART_BAUDRATE_BAUDRATE_Baud115200
    };

    APP_UART_FIFO_INIT(&comm_params,
    UART_RX_BUF_SIZE,
    UART_TX_BUF_SIZE,
    uart_event_handle,
    APP_IRQ_PRIORITY_LOW,
    err_code);

    APP_ERROR_CHECK(err_code);

    NRF_LOG("Enhanced ShockBurst Transmitter Example running.\r\n");
    printf("\r\nStart UART\r\n");
    while (true)
    {
    uint8_t cr;
    // while(app_uart_get(&cr) != NRF_SUCCESS);
    // while(app_uart_put(cr) != NRF_SUCCESS);
    NRF_LOG("Transmitting packet ");
    NRF_LOG_HEX_CHAR(tx_payload.data[1]);
    NRF_LOG("\r\n");

    tx_payload.noack = false;
    if (nrf_esb_write_payload(&tx_payload) == NRF_SUCCESS)
    {
    NRF_LOG(" Send Seccessful\r\n");
    tx_payload.data[1]++;
    if (cr == 'q' || cr == 'Q')
    {
    printf(" \n\rExit!\n\r");

    while (true)
    {
    // Do nothing.
    }
    }
    }
    }
    }

    1. When I compile my source code with preprocessor Symbol define "BSP_DEFINES_ONLY BOARD_PCA10028 NRF51", then It can print UART message "tart UART" but it can not print RTT message.

    2. When I compile my source code with proprocessor Symbol define "BSP_DEFINES_ONLY BOARD_PCA10028 ESB_PRESENT NRF_LOG_USES_RTT=1 NRF51", then the system will crash while execute "printf".

    Would you please tell me how to solve this problem?

    Thank you,

    Chianglin

  • The NUS examples (in SDK v15.0.0, at least) are using both UART and RTT together fine ...

  • Hi ,

    Thank you for your answer.

    Does "51822 version QFAAGO" can use SDK 15.0.0?

    Thank you,

    Chianglin

  • SDK12.3 is the last SDK to support the nRF51 series. 

Reply Children
Related