This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to combine the ble_app_uart with libuartes example ?

Hi,
I have a project that is comunication between nRF and Smartphone via BLE and using libuartes to comunicate with 2 another devices via 2Uarts.
Now I need to combine 2 examples into 1 project. How many stepI have to do ?
I have compared 2 sdk_config.h of 2  examples. there are some differences in 2 sdk_config.h. I think just merge them into one file

What about another files? What I need to combine them and work in 1 project step by step? 
Hope your reply soon. Thank you 
Best regard,

Parents
  • Hello,

    When combining different examples from the nRF5 SDK, my advice is usually to start with one of them (in this case I would start with the one containing the softdevice, so ble_app_uart). 

    Start by adding the libuarte functions that you see in the main.c file from the libuarte example, and the .h and .c files where these are declared and defined, respectively. Then start compiling your application, and look for the missing functions or headers. If you struggle to find what file they are defined in, look them up in the libuarte example. Remember that you need to both include the file, and enable them if they have a guard. (enable them by setting the define from sdk_config.h). If you lack the definitions from sdk_config.h, then copy them from the libuartes example.

    Give it a go, and let me know if you are stuck. 

    Best regards,

    Edvin

  • Hi Edvin,

    Thanks for your reply. I understand flow you suggested but I stuck in step how to include header file ?

    In Project Explorer window I just find .c file. 

    step1 : added the links to the folder which contain .c files in Preferences -> General -> Processors > User include directories

    step2 : then I added .c file by right clicking => add existing file.
    And I don't know where contain header file (.h file) and how to add them ?

    Addititon, How to add Dependencies and Output Files in .c file ? When I add nrfx_ppi.c I didn't find them like nrfx_gpioe.c, nrfx_clock.c....  which are already in ble_app_uart example 



  • Sorry, I meant TIMER1_ENABLED, not NRF_TIMER1_ENABLED.

    I see that TIMER1_ENABLED is set to 0. Try to set it to 1. And set TIMER_ENABLED to 1 as well. So change these on line 5443 and 5379, respectively.

    Try this first, and let me know if it doesn't work.

  • Hi Edvin,
    Above errors disappeared ^^

    But I got  new errors like this

    Building ‘ble_app_uart_pca10056_s140’ from solution ‘ble_app_uart_pca10056_s140’ in configuration ‘Debug’
    3> Compiling ‘nrf_log_backend_rtt.c’
    4> Compiling ‘nrf_log_backend_serial.c’
    5> Compiling ‘nrf_log_default_backends.c’
    6> Compiling ‘nrf_log_frontend.c’
    7> Compiling ‘nrf_log_str_formatter.c’
    8> Compiling ‘app_button.c’
    2> Compiling ‘app_error_handler_gcc.c’
    1> Compiling ‘app_error_weak.c’
    1> Compiling ‘app_fifo.c’
    4> Compiling ‘app_scheduler.c’
    5> Compiling ‘app_timer2.c’
    6> Compiling ‘app_uart_fifo.c’
    7> Compiling ‘drv_rtc.c’
    2> Compiling ‘hardfault_implementation.c’
    3> Compiling ‘nrf_atfifo.c’
    8> Compiling ‘nrf_atflags.c’
    3> Compiling ‘nrf_atomic.c’
    2> Compiling ‘nrf_balloc.c’
    1> Compiling ‘nrf_fprintf.c’
    5> Compiling ‘nrf_fprintf_format.c’
    4> Compiling ‘nrf_memobj.c’
    6> Compiling ‘nrf_pwr_mgmt.c’
    7> Compiling ‘nrf_ringbuf.c’
    8> Compiling ‘nrf_section_iter.c’
    5> Compiling ‘nrf_sortlist.c’
    3> Compiling ‘nrf_strerror.c’
    2> Compiling ‘retarget.c’
    1> Compiling ‘nrf_libuarte_async.c’
    8> Compiling ‘nrf_libuarte_drv.c’
    4> Compiling ‘nrf_queue.c’
    7> Compiling ‘boards.c’
    6> Compiling ‘nrf_drv_clock.c’
    5> Compiling ‘nrf_drv_uart.c’
    3> Compiling ‘nrfx_atomic.c’
    2> Compiling ‘nrfx_clock.c’
    7> Compiling ‘nrfx_gpiote.c’
    1> Compiling ‘nrfx_prs.c’
    4> Compiling ‘nrfx_uart.c’
    8> Compiling ‘nrfx_uarte.c’
    6> Compiling ‘nrfx_ppi.c’
    5> Compiling ‘nrfx_rtc.c’
    3> Compiling ‘nrfx_timer.c’
    7> Compiling ‘bsp.c’
    2> Compiling ‘bsp_btn_ble.c’
    5> Compiling ‘main.c’
    1> Compiling ‘SEGGER_RTT.c’
    3> Compiling ‘SEGGER_RTT_Syscalls_SES.c’
    4> Compiling ‘SEGGER_RTT_printf.c’
    6> Compiling ‘ble_advdata.c’
    7> Compiling ‘ble_advertising.c’
    8> Compiling ‘ble_conn_params.c’
    3> Compiling ‘ble_conn_state.c’
    2> Compiling ‘ble_link_ctx_manager.c’
    4> Compiling ‘nrf_ble_gatt.c’
    8> Compiling ‘nrf_ble_qwr.c’
    1> Compiling ‘ble_nus.c’
    6> Compiling ‘nrf_sdh.c’
    7> Compiling ‘nrf_sdh_ble.c’
    5> Compiling ‘nrf_sdh_soc.c’
    1> Linking ble_app_uart_pca10056_s140.elf
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_async.o: in function `nrf_libuarte_async_init':
    1> C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_async.c:480: undefined reference to `nrfx_ppi_channel_alloc'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_async.c:489: undefined reference to `nrfx_ppi_channel_assign'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_async.c:489: undefined reference to `nrfx_ppi_channel_fork_assign'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_async.c:494: undefined reference to `nrfx_ppi_channel_assign'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_async.c:494: undefined reference to `nrfx_ppi_channel_fork_assign'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_async.o: in function `nrf_libuarte_async_enable':
    1> C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_async.c:597: undefined reference to `nrfx_ppi_channel_enable'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_async.c:599: undefined reference to `nrfx_ppi_channel_enable'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_drv.o: in function `nrfx_ppi_channel_include_in_group':
    1> c:\nrf_sdk\modules\nrfx\drivers\include/nrfx_ppi.h:219: undefined reference to `nrfx_ppi_channels_include_in_group'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_drv.o: in function `ppi_channel_configure':
    1> C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:117: undefined reference to `nrfx_ppi_channel_alloc'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:123: undefined reference to `nrfx_ppi_channel_assign'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:131: undefined reference to `nrfx_ppi_channel_fork_assign'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_drv.o: in function `ppi_group_configure':
    1> C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:147: undefined reference to `nrfx_ppi_group_alloc'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:161: undefined reference to `nrfx_ppi_group_enable'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_drv.o: in function `ppi_ch_free':
    1> C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:178: undefined reference to `nrfx_ppi_channel_disable'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:180: undefined reference to `nrfx_ppi_channel_free'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_drv.o: in function `ppi_group_free':
    1> C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:189: undefined reference to `nrfx_ppi_group_free'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_drv.o: in function `ppi_ch_enable':
    1> C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:206: undefined reference to `nrfx_ppi_channel_enable'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.68/gcc/arm-none-eabi/bin/ld: Output/Debug/Obj/ble_app_uart_pca10056_s140/nrf_libuarte_drv.o: in function `ppi_ch_disable':
    1> C:\nrf_sdk\components\libraries\libuarte/nrf_libuarte_drv.c:214: undefined reference to `nrfx_ppi_channel_disable'
    Build failed
     

  • When doing this kind of work, I just start with the first error. In this case, that would be the line 63 in the log that you pasted above. 

    the compiler can't find nrfx_ppi_channel_alloc.

    So start by checking what .c (must be .c, not .h) file that defines this function in the libuarte example. Then see whether 1: Did you include this file in your current project? And 2: does this file have an #if "some sort of check" near the top of that file. If there is, and everything is working as intended, then the text that is not included in the project because of the #if will be grayed out:

    In that case, it is caused by a define in SDK_CONFIG not being set correctly. Looking at your project, it is the same situation as with the timer. I know it is not intuitive, because you already set "#define NRFX_PPI_ENABLED 1", but there exists a file called "apply_old_config.h" which will check if both "legacy" definitions and "nrfx" definitions of the same peripherals/libraries are defined, and if they are, then it will overwrite the nrfx one based on the legacy one. So in this case, you set the NRFX_PPI_ENABLED to 1, but PPI_ENABLED 0 is set to 0. Looking at apply_old_config,h, line 411:

    #if defined(PPI_ENABLED)
    
    #undef NRFX_PPI_ENABLED
    #define NRFX_PPI_ENABLED  PPI_ENABLED

    It will undefine NRFX_PPI_ENABLED that you set in sdk_config.h, and give it the same value as PPI_ENABLED, which is 0.

    Ignore the "gray out" in the apply_old_config.h. The compiler is confused of the undef and re defining.

    So to work around the "legacy" and "nrfx" double definitions:

    1: Either use the non-nrfx definitions when they are defined.

    2: or set them to match eachother.

    3: or remove the non-nrfx definitions when nrfx definitions are present.

  • So to work around the "legacy" and "nrfx" double definitions:

    1: Either use the non-nrfx definitions when they are defined.

    2: or set them to match eachother.

    3: or remove the non-nrfx definitions when nrfx definitions are present.

    Hi Edvin, Can you give me some examples. I'm new embedded so it's really hard to understand. Thank you so much for quick replies

  • Let us take the PPI_ENABLED as an example.

    If PPI_ENABLED and NRFX_PPI_ENABLED are both defined. Then the compiler will use PPI_ENABLED and ignore NRFX_PPI_ENABLED.

    If only PPI_ENABLED is defined, then the compiler will use that.

    If only NRFX_PPI_ENABLED is defined, then the compiler will use that.

Reply
  • Let us take the PPI_ENABLED as an example.

    If PPI_ENABLED and NRFX_PPI_ENABLED are both defined. Then the compiler will use PPI_ENABLED and ignore NRFX_PPI_ENABLED.

    If only PPI_ENABLED is defined, then the compiler will use that.

    If only NRFX_PPI_ENABLED is defined, then the compiler will use that.

Children
No Data
Related