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

nRF52 UART example on a custom board, compile problems

Hello

First things first, when I use the UART example located in:

\nRF5_SDK_15.2.0_9412b96\examples\peripheral\uart\pca10040\blank\ses

all works fine, the script compiles properly and I am able to see things being sent over serial in Tera Term

I then tried cutting down the example & modifying the IO pins to match with my custom board, again it compiles fine:

#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include "app_uart.h"
//#include "app_error.h"
#include "nrf_delay.h"
//#include "nrf.h"
#include "nrf_uart.h"

#include "custom_board.h"

#define MAX_TEST_DATA_BYTES     (15U)                /**< max number of test bytes to be used for tx and rx. */
#define UART_TX_BUF_SIZE 256                         /**< UART TX buffer size. */
#define UART_RX_BUF_SIZE 256                         /**< UART RX buffer size. */

void uart_error_handle(app_uart_evt_t * p_event)
{
    if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR)
    {
        APP_ERROR_HANDLER(p_event->data.error_communication);
    }
    else if (p_event->evt_type == APP_UART_FIFO_ERROR)
    {
        APP_ERROR_HANDLER(p_event->data.error_code);
    }
}

int main(void)
{
  uint32_t err_code;

  const app_uart_comm_params_t comm_params =
    {
        RX_PIN_NUMBER,
        TX_PIN_NUMBER,
        RTS_PIN_NUMBER,
        CTS_PIN_NUMBER,
        UART_HWFC,
        false,
        NRF_UART_BAUDRATE_115200
    };

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

  APP_ERROR_CHECK(err_code);

  printf("\r\nRestarting \r\n");

  while (true)
  {
    printf("\r\nLine one =^..^= \r\n");
    nrf_delay_ms(1000);
    printf("\r\nLine twooo =^..^= \r\n");
    nrf_delay_ms(1000);
  }
}

The problem comes when I try and move the above into a new SES project, where I also made sure that all libraries are linked. When I try and compile the above in my new project I get the following errors:

Building ‘TEST_UART’ from solution ‘TEST_UART’ in configuration ‘Debug’
Compiling ‘main.c’
Linking TEST_UART.elf
Output/TEST_UART Debug/Obj/main.o: In function `uart_error_handle':
undefined reference to `app_error_handler'
undefined reference to `app_error_handler'
Output/TEST_UART Debug/Obj/main.o: In function `main':
undefined reference to `app_uart_init'
undefined reference to `app_error_handler'
Build failed

I then had a look inside "app_uart.h" and strangely app_uart_init() is defined there, and "app_error.h" has app_error_handler(). So the question is what silly mistake did I manage to make ?_?

Also here is a link to the above project if anyone wants to have a go at compiling it themselves:

drive.google.com/.../1gjVHYitp5elQC6wIEVYtFDnuvhm8aL83

\nRF52&UART_2019Jan20\xTests\04_2019Jan19_UART\TEST_UART.emProject

And here is a link to the modified example which compiles fine:

drive.google.com/.../1QyD_aWLo4y6tENhzKKjG48rMdWuV4gOP

nRF5_SDK_15.2.0_9412b96_EDIT\examples\peripheral\uart\pca10040\blank\ses\uart_pca10040.emProject

Parents Reply Children
No Data
Related