Project files problem with uart

im trying to use the uart functionality in another project. i implemented uart using the uart example project and i got it working. the next stage is that i want to implement uart in another project. but i cant get it to work. i keep getting errors about missing files can someone walk me through how to do it ?

im using segger embedded studio v5.7a with nrf52840 and sdk 17.1

Parents
  • for more details here is my main.c

    #include <stdbool.h>
    #include <stdint.h>
    #include <stdio.h>
    #include "app_uart.h"
    #include "nrf52840.h"
    #include "nrf_delay.h"
    #include "nrf.h"
    #include "nrf_uart.h"
    #include "boards.h"
    
    #define UART_TX_BUFF_SIZE  128
    #define UART_RX_BUFF_SIZE  128
    
    #define UART_HWFC APP_UART_FLOW_CONTROL_DISABLED
    
    void uart_err_handle(app_uart_evt_type_t* p)
    {
        
    }
    
    int main(void)
    {
       nrf_gpio_cfg_output(13);
       nrf_gpio_pin_set(13);
    nrf_gpio_pin_clear(13);
    uint32_t err_code;
       const app_uart_comm_params_t com_params = 
      {8, //RX
       6, //TX
       5,
       7,
       UART_HWFC,
       false,
       NRF_UART_BAUDRATE_9600};
    
       APP_UART_FIFO_INIT(&com_params,UART_RX_BUFF_SIZE,UART_TX_BUFF_SIZE,uart_err_handle,APP_IRQ_PRIORITY_LOWEST,err_code);
       
       while(1)
        {
          printf("done");
          nrf_delay_ms(500);
        }
       
    }

    and what i did till now was insert the files of app_uart.c and app_uart_fifo.c and retarget.c to my project by usineg "add existing files"

    then i added the directory of app_uart.h by project->options->preprocessor-> user include directories

    right now it is giving me this error (undefined reference to `app_uart_init') which is a function called in app_uart.h and is defined in app_uart_fifo.c

    any suggestions whether im in the right path or what am i missing ?

  • Hello bido1234,

    bido1234 said:

    and what i did till now was insert the files of app_uart.c and app_uart_fifo.c and retarget.c to my project by usineg "add existing files"

    then i added the directory of app_uart.h by project->options->preprocessor-> user include directories

    right now it is giving me this error (undefined reference to `app_uart_init') which is a function called in app_uart.h and is defined in app_uart_fifo.c

    any suggestions whether im in the right path or what am i missing ?

    It sounds like you have done most of it correct already, but could you also confirm whether or not you have made any changes to the sdk_config.h file? This file will need to be edited to enable and configure new peripherals and libraries from the SDK. For the app_uart you will need APP_UART_ENABLED defined in your sdk_config.h.

    Furthermore, you should make sure that the sdk_config.h file does not contain any conflicting legacy defines and configurations when you are intending to use the nrfx drivers (such as the legacy UART_ENABLED define, when you intend to use the NRFX_UART_ENABLED, for example).
    If these legacy definitions are present they will through the apply_old_config file overwrite your nrfx driver configuration at compile-time.

    Best regards,
    Karl

  • i got it working the problem was the sdk_config.h there were missing lines. so i copied the lines from the uart project sdk_config to the other projects sdk_config and it worked. my question is, what if i didnt see the missing lines in the sdk_config ? the sdk_config is a huge file and it would be understandable if i didnt go over the difference between it and the other sdk_config line by line so is there another way to do this ?

    and thank you for replying

  • bido1234 said:
    i got it working the problem was the sdk_config.h there were missing lines. so i copied the lines from the uart project sdk_config to the other projects sdk_config and it worked

    I am happy to hear that you got it working! :) 

    bido1234 said:
    my question is, what if i didnt see the missing lines in the sdk_config ? the sdk_config is a huge file and it would be understandable if i didnt go over the difference between it and the other sdk_config line by line so is there another way to do this ?

    That is a fair question, and I suppose it comes down to familiarity with nRF5 SDK development, unfortunately.
    We have multiple guides that introduces the nRF5 SDK development and that establishes the importance of the sdk_config.h file, but other than that and its placement right next to main.c in the project hierarchy, there is no explanation for it or documentation in the development environment.

    On a general note about going over file differences I would highly recommend using the diff command (linux) or similar Windows tool to check for differences between two files, so that you may have all the differences highlighted.

    Best regards,
    Karl

Reply
  • bido1234 said:
    i got it working the problem was the sdk_config.h there were missing lines. so i copied the lines from the uart project sdk_config to the other projects sdk_config and it worked

    I am happy to hear that you got it working! :) 

    bido1234 said:
    my question is, what if i didnt see the missing lines in the sdk_config ? the sdk_config is a huge file and it would be understandable if i didnt go over the difference between it and the other sdk_config line by line so is there another way to do this ?

    That is a fair question, and I suppose it comes down to familiarity with nRF5 SDK development, unfortunately.
    We have multiple guides that introduces the nRF5 SDK development and that establishes the importance of the sdk_config.h file, but other than that and its placement right next to main.c in the project hierarchy, there is no explanation for it or documentation in the development environment.

    On a general note about going over file differences I would highly recommend using the diff command (linux) or similar Windows tool to check for differences between two files, so that you may have all the differences highlighted.

    Best regards,
    Karl

Children
No Data
Related