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

nrf51822 uart only works when connected to debugger

Hi,

I am using nRF5_SDK_12.3.0 and writing customized firmware based on uart example.

Everything works fine with the DK. Then I program the firmware to a nrf51822 module using the DK after modifying the board definition to fix my customized board. 

My firmware will send out a start up message though uart after uart initiation. However, I can only capture that uart message if the customized board is connected with the DK.

Here is my initialization code:

    #define RX_PIN_NUMBER  UART_PIN_DISCONNECTED
    #define TX_PIN_NUMBER  3
    #define CTS_PIN_NUMBER UART_PIN_DISCONNECTED
    #define RTS_PIN_NUMBER UART_PIN_DISCONNECTED

    const app_uart_comm_params_t comm_params =
      {
          RX_PIN_NUMBER,
          TX_PIN_NUMBER,
          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_error_handle,
                         APP_IRQ_PRIORITY_LOWEST,
                         err_code);

I have also tried to send message periodically as followings:

        uart_tx_length = sprintf(uart_tx_buf, "START\r\n");

        while(true)
        {
            nrf_delay_ms(250);
            user_uart_write(uart_tx_buf, uart_tx_length);
            
        }

where user_uart_write is as follows:

void user_uart_write(char *buf, uint8_t length)
{
    for (uint32_t i = 0; i < length; i++)
    {
            while (app_uart_put(buf[i]) != NRF_SUCCESS);
    }
}

It keep sending the "START\r\n" when connected to the DK and stop when I unplug the customized board from it.

Any idea what have I don't wrong?

Related