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

2 UARTs on 51422

Hi,

I have a hardware (wired) UART transmitting data to the nRF51 at intervals. I'm currently trying to implement UART-BLE that runs could concurrently with the wired UART.

How should I go about doing that (uart event handler and uart initialization)?

Parents Reply Children
  • Hi Stefan,

    I'm looking to receive data from 2 ends independently:

    1. From hardware UART (receiving data from another chip)
    2. From BLE-UART (receiving data from mobile app)

    Also, due to my hardware limitation, I'm only able to use the same UART pin for both wired uart and ble-uart. I don't think it is covered in SDK's BLE UART.

  • Or to rephrase it, how do i know which data is coming from hw uart and ble-uart from the uart_evt_handler?

  • Hi

    The uart_evt_handler is callback function for the hardware UART. The nus_data_handler is the callback function for the BLE-UART messages. The nus service is initialized in the services_init function, where the BLE-UART nus_data_handler callback is set.

    You can see in the nus_data_handler in the example that the data received from BLE-UART is directly forwarded to the hardware UART. You can also see in the uart_event_handle that data received on the hardware UART is directly forwarded to the BLE-UART. This means that the data can flow in both directions, from a BLE peer device to a hardware connected UART device, and also from hardware connected UART device to a BLE peer device.

    You can connect to the hardware UART with a UART terminal program on your PC, e.g. Realterm, and communicate with for example Master Control Panel on Win PC or any BLE analyzing app on your smartphone, or most simply, use the nRFToolbox UART app, available for IOS, Android and windows phone

Related