nRF51 SDK - S110 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 configure pins needs to be redirected to a COM port (terminal programs like putty can listen to this COM port through a terminal session). When the program starts it will transmit "START: " through this serial device using simple_uart_putstring and this should be visible on the terminal. All typed characters on this terminal will be transmitted to the program through simple_uart_get and when an exit character 'q' or 'Q' is typed the program will end into an infinite loop after transmitting "EXIT!" on a new line of the terminal.

Note
This example is not just for COM ports but can be used for any UART connection, COM port redirection is for visual verification.
Setting the define ENABLE_LOOPBACK_TEST will assume that the TX_PIN_NUMBER is connected to RX_PIN_NUMBER, used to test in loopback. In this case no com port can be used as the data flows from TX to RX and ERROR_PIN is set high if data is lost.
Settings: Baud: 38400, data bits: 8 , Stop Bits: 1.

The source code and project file are available for both development and evaluation boards and is located in the following folders:
<InstallFolder>\Nordic\nrf51822\Board\nrf6310\uart_example
<InstallFolder>\Nordic\nrf51822\Board\pca10000\uart_example
<InstallFolder>\Nordic\nrf51822\Board\pca10001\uart_example
<InstallFolder>\Nordic\nrf51422\Board\pca10003\uart_example

Setup

Instructions on how to set up the nRFgo Motherboard: nRFgo Motherboard Setup (nRF6310).

Writing 'Q' or 'q' to the PUTTY terminal ends the program.

Testing

The UART Example Application can be tested as follows:

  1. Compile and program the application.
  2. Start a COM listener like PUTTY and connect to the used COM port at 38400 baud rate.
  3. The text "Start:" should appear at the top of the terminal.
  4. Type 'Q' or 'q' in the terminal.
  5. The response should be 'Exit!'.