nRF5 SDK v15.3.0
UART Example

The UART Example demonstrates basic UART usage for communicating with a PC terminal. It transmits and receives data through the configured pins as a serial device. The configured pins must be redirected to a COM port. Terminal programs (for example PUTTY) can listen to this COM port through a terminal session.

When the application starts, it transmits "START: " through the serial device. This will be output on the terminal. If you type characters on the terminal, they are transmitted to the application through app_uart_get. If you type an exit character 'q' or 'Q', the program transmits "EXIT!" on a new line and ends into an infinite loop.

This example can be used for any UART connection, not only COM ports. COM port redirection is used for visual verification.

If you set the define ENABLE_LOOPBACK_TEST, the application will assume that the TX_PIN_NUMBER is connected to RX_PIN_NUMBER and RTS_PIN_NUMBER is connected to CTS_PIN_NUMBER, used to test in loopback. In this case, no COM port can be used because the data flows from TX to RX. If data is lost, ERROR_PIN is set high.

You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\peripheral\uart


Test the UART Example application by performing the following steps:

  1. Compile and program the application.
  2. Start a terminal emulator like PuTTY and connect to the used COM port with the following UART settings:
    • Baud rate: 115.200
    • 8 data bits
    • 1 stop bit
    • No parity
    • HW flow control: None
  3. Observe that the text "Start:" appears at the top of the terminal.
  4. Type 'Q' or 'q' in the terminal. The response should be 'Exit!'.

Documentation feedback | Developer Zone | Subscribe | Updated