nRF51 SDK - S210 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
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.

Note
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.
Settings:
  • Baud: 38400
  • Data bits: 8
  • Stop bits: 1

The name of the example is uart_pca10028. If you are not using the Keil Pack Installer, you can find the source code and project file of the example in the following folder: <InstallFolder>\examples\peripheral\uart

Testing

Test the UART Example application by performing the following steps:

  1. Compile and program the application.
  2. Start a COM listener like PUTTY and connect to the used COM port with the following UART settings:
    • Baud rate: 38.400
    • 8 data bits
    • 1 stop bit
    • No parity
    • HW flow control: RTS/CTS
  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!'.