Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

[SOLVED] nrf_serial.c with nRF52032 - only first-time string printed to terminal

[SOLVED] turn off logging through UART.

Hello

I'm experiencing a strange issue where my device sends a beacon under DEBUG, but does not under RUN.

Due to that I tried to have the debug status written to a terminal.

I included nrf_serial.c and used default setup.

I call this and it prints "Hello nrf_serial!".

void serial_init(void)
{
     ret_code_t ret;
     ret = nrf_serial_init(&serial_uart, &m_uart0_drv_config, &serial_config);
     APP_ERROR_CHECK(ret);
     static char tx_message[] = "Hello nrf_serial!\n\r";
     ret = nrf_serial_write(&serial_uart,
          tx_message,
          strlen(tx_message),
          NULL,
          NRF_SERIAL_MAX_TIMEOUT);
     APP_ERROR_CHECK(ret);
     ret = nrf_serial_flush(&serial_uart, NRF_SERIAL_MAX_TIMEOUT);
     APP_ERROR_CHECK(ret);
}

then I do this: serial_init();
printf("\r\nTEST UART\r\n");
s_write("tst0\r\n");
s_write("tst1\r\n");
s_write("tst2\r\n");
s_write("tst3\r\n");
s_write("tst4\r\n");

neither of the "tst..." messages is written.

The s_write contains this:

ret = nrf_serial_write(&serial_uart, c, strlen(c), NULL, NRF_SERIAL_MAX_TIMEOUT);
APP_ERROR_CHECK(ret);
ret = nrf_serial_flush(&serial_uart, NRF_SERIAL_MAX_TIMEOUT);
APP_ERROR_CHECK(ret);

Is it an interrupt issue? 

  • [SOLVED] - turn off logging through UART. Debug through RTT.

    This code (taken from the serial example):

    void serial_init(void)
    {
    ret_code_t ret;
    ret = nrf_drv_clock_init();
    APP_ERROR_CHECK(ret);
    ret = nrf_drv_power_init(NULL);
    APP_ERROR_CHECK(ret);

    nrf_drv_clock_lfclk_request(NULL);
    ret = app_timer_init();
    APP_ERROR_CHECK(ret);

    ret = nrf_serial_init(&serial_uart, &m_uart0_drv_config, &serial_config);
    APP_ERROR_CHECK(ret);
    static char tx_message[] = "Hello nrf_serial!\n\r";
    ret = nrf_serial_write(&serial_uart,
    tx_message,
    strlen(tx_message),
    NULL,
    NRF_SERIAL_MAX_TIMEOUT);
    APP_ERROR_CHECK(ret);
    ret = nrf_serial_flush(&serial_uart, NRF_SERIAL_MAX_TIMEOUT);
    APP_ERROR_CHECK(ret);
    }

    Returns "8" from ret = nrf_serial_init(&serial_uart, &m_uart0_drv_config, &serial_config);

    Note: I am using this in scan and forward mode with 4 channels. 

Related