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

Receiving data from UART via a peripheral device

Hi

I am working with a Nordic nrf52840dk using segge and sdk 16.

I am using the nordic UART example in examples/peripheral/uart.

The issue I am having is that my data being sent to this device can not be read from the nordic board.

Below is an example of the code going into my Putty terminal from my UART peripheral device.

1,1183,1,1169
1,1183,1,1169
1,1183,1,1169
1,1183,1,1169
1,1183,1,1169
1,1183,1,1169

This device has 4 wire connections RX,TX,CTS and RTS. My connections are listed below:

Note this is the default.

#define RX_PIN_NUMBER  8
#define TX_PIN_NUMBER  6
#define CTS_PIN_NUMBER 7
#define RTS_PIN_NUMBER 5

The first thing i tried was running the code with no change to see if app_uart_get(&cr) would pull this data. Unfortunately it did not. It does however, pull data that i type into the terminal.

What I want to do is to take this data from the UART(Sensor data) and store it as a variable for handling later on.

I which to know how I can pull this data from the serial connection.

Side note when the device (UART) is plugged in printing from putty does not run. If I unplug the device then printing works fine.  Below is my main code (from example).

int main(void)
{
    uint32_t err_code;

    bsp_board_init(BSP_INIT_LEDS);

    const app_uart_comm_params_t comm_params =
      {
          RX_PIN_NUMBER,
          TX_PIN_NUMBER,
          RTS_PIN_NUMBER,
          CTS_PIN_NUMBER,
          UART_HWFC,
          false,
#if defined (UARTE_PRESENT)
          NRF_UARTE_BAUDRATE_115200
#else
          NRF_UARTE_BAUDRATE_115200
#endif
/*
#if defined (UART_PRESENT)
          NRF_UART_BAUDRATE_115200
#else
          NRF_UARTE_BAUDRATE_115200
#endif
*/
      };

    APP_UART_FIFO_INIT(&comm_params,
                         UART_RX_BUF_SIZE,
                         UART_TX_BUF_SIZE,
                         uart_error_handle,
                         APP_IRQ_PRIORITY_HIGH,
                         //APP_IRQ_PRIORITY_LOWEST,
                         err_code);

    APP_ERROR_CHECK(err_code);

#ifndef ENABLE_LOOPBACK_TEST
    printf("\r\nUART example started.\r\n");

    while (true)
    {
        uint8_t cr;
        while (app_uart_get(&cr) != NRF_SUCCESS);
        while (app_uart_put(cr) != NRF_SUCCESS);

        if (cr == 'q' || cr == 'Q')
        {
            printf(" \r\nExit!\r\n");

            while (true)
            {
                // Do nothing.
            }
        }
    }
#else

    // This part of the example is just for testing the loopback .
    while (true)
    {
        uart_loopback_test();
    }
#endif
}

Parents Reply Children
  • No I have'nt manually included the c file (app_uart_fifo.c).

    How do I do this?

  • I've include it (added an exisitng file) via the project items list.

    But, when I build now i get app_fifo.h no such file or directory. This error runs from app_uart_fifo.c

  • I've tried including the directory which, app_fifo.h resides in.

    ../../../../../components/libraries/uart
    ../../../../../components/libraries/fifo

  • Hi,

    If it is correctly in the include path than it should be found. There are two typical issues when adding include paths:

    1. An incorrect number of "../". This is relative to the project file. But if it is the same as those includes that were already in the project, and it works, then this should be OK.
    2. Whitespace after the end of the path. E.g. if it really is "../../../../../components/libraries/uart " instead of "../../../../../components/libraries/uart". You will not see this without putting the cursor at the end of the line or highlighting it.

    Do you still have problems after doublechecking this?

  • Yeah was the number of ../

    Now i get undefined reference to app_fifo_put and app_fifo_init

    Building ‘ble_app_beacon_pca10056_s140’ from solution ‘ble_app_beacon_pca10056_s140’ in configuration ‘Release’
      Compiling ‘app_uart_fifo.c’
      Compiling ‘main.c’
      Generating linker script ‘ble_app_beacon_pca10056_s140.ld’
      Linking ble_app_beacon_pca10056_s140.elf
        Output/ble_app_beacon_pca10056_s140 Release/Obj/app_uart_fifo.o: in function `uart_event_handler':
        undefined reference to `app_fifo_put'
        D:\Segger projects\Segger Projects\DeviceDownload2\components\libraries\uart/app_uart_fifo.c:119: undefined reference to `app_fifo_get'
        Output/ble_app_beacon_pca10056_s140 Release/Obj/app_uart_fifo.o: in function `app_uart_init':
        undefined reference to `app_fifo_init'
        D:\Segger projects\Segger Projects\DeviceDownload2\components\libraries\uart/app_uart_fifo.c:156: undefined reference to `app_fifo_init'
        Output/ble_app_beacon_pca10056_s140 Release/Obj/app_uart_fifo.o: in function `app_uart_get':
        undefined reference to `app_fifo_get'
    Build failed

Related