nRF51 SDK - S120 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 using simple_uart_putstring. This will be output on the terminal. If you type characters on the terminal, they are transmitted to the application through simple_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>\Nordic\nrf51\example\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 at 38400 baud rate. The text "Start:" should appear at the top of the terminal.
  3. Type 'Q' or 'q' in the terminal. The response should be 'Exit!'.