Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

adding ble app uart into a peripheral example

Hi,

I am trying to add the ble-app-uart example into the saadc example. I added all needed files.c which there were not in the saadc project and also all paths in the user include path in the project option. I also added all #include needed for the uart example in the main.c file of the saadc project.

I faced a lot of errors such as:

error: 'NRF_SDH_BLE_TOTAL_LINK_COUNT' undeclared here (not in a function); did you mean 'NRF_BLE_GATT_LINK_COUNT

and

error: 'BLE_NUS_BLE_OBSERVER_PRIO' undeclared here (not in a function); did you mean 'APP_BLE_OBSERVER_PRIO'?

and so on...

I tried to add codes into the sdk_config.c to eliminate the errors. But it seems that this is not the correct way.

Could you please help me?

Thank you,

Sama

Parents
  • Hi Sama,

    There are two possible issue while merging two sample projects.

    1. sdk_config.h flags are not present or enable

    - Try to compare the sdk_config.h files of both the projects and add the missing flags. Once compared and updated all the configurations from ble-app-uart example into the saadc example check if errors are reduced.

    2. Library path is not added into build configuration

    - Fir that compare library paths and add if absent

     In my experience it is always easy to add code from peripheral examples into ble examples. If nothing is working try to add code from saadc example into ble-app-uart example, very less configuration is required in project to add peripherals.

    Regards

  • Hi

    Thank you for your reply.

    I compared the sdk_config.h files of both the projects and added every line which there is not in the sdk_config of SADDC.

    I compared the flash placement file and found that something there is not in the flash placement of the SADDC project, so I added them. 

    the number of errors reduced but finally, I faced with these errors:

    Output/Release/Obj/saadc_pca10056/main.o: in function `ble_evt_handler':

    this is the log:

     Rebuilding ‘saadc_pca10056’ from solution ‘saadc_pca10056’ in configuration ‘Release’
    1> Assembling ‘thumb_crt0.s’
    2> Compiling ‘nrf_log_backend_rtt.c’
    3> Compiling ‘nrf_log_backend_serial.c’
    4> Compiling ‘nrf_log_backend_uart.c’
    1> Compiling ‘nrf_log_default_backends.c’
    2> Compiling ‘nrf_log_frontend.c’
    3> Compiling ‘nrf_log_str_formatter.c’
    4> Compiling ‘app_error.c’
    1> Compiling ‘app_error_handler_gcc.c’
    4> Compiling ‘app_error_weak.c’
    3> Compiling ‘app_util_platform.c’
    2> Compiling ‘nrf_assert.c’
    1> Compiling ‘nrf_atomic.c’
    4> Compiling ‘nrf_balloc.c’
    2> Compiling ‘nrf_fprintf.c’
    3> Compiling ‘nrf_fprintf_format.c’
    1> Compiling ‘nrf_memobj.c’
    4> Compiling ‘nrf_pwr_mgmt.c’
    2> Compiling ‘nrf_ringbuf.c’
    3> Compiling ‘nrf_section_iter.c’
    1> Compiling ‘nrf_strerror.c’
    4> Compiling ‘nrf_drv_ppi.c’
    2> Compiling ‘nrf_drv_uart.c’
    3> Compiling ‘nrfx_atomic.c’
    1> Compiling ‘nrfx_ppi.c’
    4> Compiling ‘nrfx_prs.c’
    2> Compiling ‘nrfx_saadc.c’
    3> Compiling ‘nrfx_timer.c’
    4> Compiling ‘nrfx_uart.c’
    1> Compiling ‘nrfx_uarte.c’
    2> Compiling ‘main.c’
    3> Compiling ‘SEGGER_RTT.c’
    2> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\main.c:147:1: warning: data definition has no type or storage class
    2> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\main.c:147:1: warning: type defaults to 'int' in declaration of 'Max_Sample' [-Wimplicit-int]
    1> Compiling ‘SEGGER_RTT_Syscalls_SES.c’
    4> Compiling ‘SEGGER_RTT_printf.c’
    1> Assembling ‘ses_startup_nrf52840.s’
    1> Assembling ‘ses_startup_nrf_common.s’
    2> Compiling ‘system_nrf52840.c’
    4> Compiling ‘Calculate_param.c’
    1> Compiling ‘calculate_cross_zero.c’
    3> Compiling ‘Wave1_Calculations.c’
    4> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Calculate_param.c:59:8: warning: implicit declaration of function 'SeprateVoltage' [-Wimplicit-function-declaration]
    4> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Calculate_param.c:82:3: warning: implicit declaration of function 'Wave1_Calculations' [-Wimplicit-function-declaration]
    4> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Calculate_param.c:84:4: warning: implicit declaration of function 'Wave2_Calculations' [-Wimplicit-function-declaration]
    4> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Calculate_param.c:86:2: warning: implicit declaration of function 'Wave3_Calculations' [-Wimplicit-function-declaration]
    4> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Calculate_param.c:88:3: warning: implicit declaration of function 'Wave4_Calculations' [-Wimplicit-function-declaration]
    3> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Wave1_Calculations.c:54:3: warning: implicit declaration of function 'SeprateCurrent' [-Wimplicit-function-declaration]
    3> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Wave1_Calculations.c:55:3: warning: implicit declaration of function 'Calculate_VRMS_IRMS' [-Wimplicit-function-declaration]
    3> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Wave1_Calculations.c:116:6: warning: conflicting types for 'SeprateCurrent'
    3> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Wave1_Calculations.c:54:3: note: previous implicit declaration of 'SeprateCurrent' was here
    4> Compiling ‘calculate_VRMS_IRMS.c’
    1> Compiling ‘Wave2_Calculations.c’
    1> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Wave2_Calculations.c:22:7: warning: implicit declaration of function 'SeprateVoltage' [-Wimplicit-function-declaration]
    1> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Wave2_Calculations.c:23:7: warning: implicit declaration of function 'SeprateCurrent' [-Wimplicit-function-declaration]
    1> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Wave2_Calculations.c:24:7: warning: implicit declaration of function 'Calculate_VRMS_IRMS' [-Wimplicit-function-declaration]
    3> Compiling ‘Wave3_Calculations.c’
    1> Compiling ‘Wave4_Calculations.c’
    3> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Wave3_Calculations.c:20:7: warning: implicit declaration of function 'SeprateVoltage' [-Wimplicit-function-declaration]
    3> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Wave3_Calculations.c:21:7: warning: implicit declaration of function 'SeprateCurrent' [-Wimplicit-function-declaration]
    3> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Wave3_Calculations.c:22:7: warning: implicit declaration of function 'Calculate_VRMS_IRMS' [-Wimplicit-function-declaration]
    2> Compiling ‘match.c’
    4> Compiling ‘bsp.c’
    1> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Wave4_Calculations.c:24:7: warning: implicit declaration of function 'SeprateVoltage' [-Wimplicit-function-declaration]
    1> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Wave4_Calculations.c:25:7: warning: implicit declaration of function 'SeprateCurrent' [-Wimplicit-function-declaration]
    1> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses\calculation\Wave4_Calculations.c:26:7: warning: implicit declaration of function 'Calculate_VRMS_IRMS' [-Wimplicit-function-declaration]
    3> Compiling ‘bsp_btn_ble.c’
    1> Compiling ‘ble_advdata.c’
    4> Compiling ‘ble_conn_params.c’
    2> Compiling ‘ble_conn_state.c’
    3> Compiling ‘ble_srv_common.c’
    1> Compiling ‘ble_advertising.c’
    4> Compiling ‘ble_link_ctx_manager.c’
    2> Compiling ‘nrf_ble_gatt.c’
    3> Compiling ‘nrf_ble_qwr.c’
    1> Compiling ‘ble_nus.c’
    4> Compiling ‘utf.c’
    2> Compiling ‘nrfx_gpiote.c’
    3> Compiling ‘nrf_drv_clock.c’
    4> Compiling ‘nrfx_clock.c’
    1> Compiling ‘app_button.c’
    3> Compiling ‘app_fifo.c’
    4> Compiling ‘app_scheduler.c’
    2> Compiling ‘app_timer2.c’
    1> Compiling ‘app_uart_fifo.c’
    4> Compiling ‘drv_rtc.c’
    3> Compiling ‘hardfault_implementation.c’
    2> Compiling ‘nrf_atfifo.c’
    1> Compiling ‘nrf_atflags.c’
    3> Compiling ‘nrf_sortlist.c’
    4> Compiling ‘retarget.c’
    2> Compiling ‘nrf_sdh_ble.c’
    1> Compiling ‘nrf_sdh_soc.c’
    3> Compiling ‘nrf_sdh.c’
    4> Compiling ‘boards.c’
    1> Generating linker script ‘saadc_pca10056.ld’
    1> Linking saadc_pca10056.elf
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.34/gcc/arm-none-eabi/bin/ld: Output/Release/Obj/saadc_pca10056/main.o: in function `ble_evt_handler':
    1> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses/main.c:507: undefined reference to `nrf_ble_qwr_conn_handle_assign'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.34/gcc/arm-none-eabi/bin/ld: Output/Release/Obj/saadc_pca10056/main.o: in function `bsp_event_handler':
    1> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses/main.c:641: undefined reference to `ble_advertising_restart_without_whitelist'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.34/gcc/arm-none-eabi/bin/ld: Output/Release/Obj/saadc_pca10056/main.o: in function `gatt_init':
    1> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses/main.c:609: undefined reference to `nrf_ble_gatt_init'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.34/gcc/arm-none-eabi/bin/ld: D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses/main.c:612: undefined reference to `nrf_ble_gatt_att_mtu_periph_set'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.34/gcc/arm-none-eabi/bin/ld: Output/Release/Obj/saadc_pca10056/main.o: in function `services_init':
    1> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses/main.c:378: undefined reference to `nrf_ble_qwr_init'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.34/gcc/arm-none-eabi/bin/ld: Output/Release/Obj/saadc_pca10056/main.o: in function `advertising_init':
    1> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses/main.c:768: undefined reference to `ble_advertising_init'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.34/gcc/arm-none-eabi/bin/ld: D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses/main.c:771: undefined reference to `ble_advertising_conn_cfg_tag_set'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.34/gcc/arm-none-eabi/bin/ld: Output/Release/Obj/saadc_pca10056/main.o: in function `conn_params_init':
    1> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses/main.c:442: undefined reference to `ble_conn_params_init'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.34/gcc/arm-none-eabi/bin/ld: Output/Release/Obj/saadc_pca10056/main.o: in function `advertising_start':
    1> D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses/main.c:831: undefined reference to `ble_advertising_start'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.34/gcc/arm-none-eabi/bin/ld: Output/Release/Obj/saadc_pca10056/main.o:D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses/main.c:134: undefined reference to `ble_advertising_on_ble_evt'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.34/gcc/arm-none-eabi/bin/ld: Output/Release/Obj/saadc_pca10056/main.o:D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses/main.c:132: undefined reference to `nrf_ble_gatt_on_ble_evt'
    1> C:/Program Files/SEGGER/SEGGER Embedded Studio for ARM 5.34/gcc/arm-none-eabi/bin/ld: Output/Release/Obj/saadc_pca10056/main.o:D:\Behine Niroo\Nordic\nRF5_SDK_17.0.2_d674dde\examples\peripheral\SAADC.V1.7.0.13991203 - Test for adding ble-uart\pca10056\blank\ses/main.c:133: undefined reference to `nrf_ble_qwr_on_ble_evt'
    Build failed

    Is there any solution?

    I have to add UART to SAADC as my boss wants.

    I have wasted a great deal of time to do this task.

    Please help.

    thanks,

    Sama

  • Are you following our advice of merging SAADC into the BLE example? Also, you have to make sure to also add the path of the folder where the source files are located, see this

Reply Children
  • I added all path of the file I added to the project.
    I compare and change the config_sdk manually. I copied lines of the sdk_config of the UART example which there is not int the sdk_config of the SAADC. Does it make a problem?

    Thank you

  • Hi

    I noticed that saadc project is non softdevice project where as ble operations are dependent on softdevice. You have to make changes according to that as well.

    Again i will recommend to merge saadc into ble example as most of project configurations will be there and working correctly.

    Regards

  • finally was able to eliminate the errors and modify the code without any error.

    Now, when I send the program on the devkit, it does not advertise. When I debug, it gets stuck in the app_error_weak.c file where the NRF_BREAKPOINT_COND placed, as you can see in the image below.

    I searched the error code, but I did not find anything.
    Could you please guide me?

    Br,

    Sama

  • What is calling the error handler? How far does the program reach before it enters the error handler? Try setting a couple of breakpoints and see if the program reaches it. 

  • Hi, 

    Here is my main function:

    int main(void)
    {


    bool erase_bonds;

    // Initialize.
    uart_init();
    log_init();
    timers_init();
    buttons_leds_init(&erase_bonds);
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();

    uint8_t read_data[64];
    long unsigned int Time1,Time2,Time3;
    uint32_t err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();

    ret_code_t ret_code = nrf_pwr_mgmt_init();
    APP_ERROR_CHECK(ret_code);


    saadc_sampling_event_init();
    saadc_init();
    saadc_sampling_event_enable();


    // Start execution.
    printf("\r\nUART started.\r\n");
    NRF_LOG_INFO("Debug logging for UART over RTT started.");
    advertising_start();

    while (1) {

    Time1=TimeLineFun(0);
    //printf("T=%d",Time1);
    idle_state_handle();

    while ( Counter <= Max_Sample)
    {

    nrf_delay_ms(1);
    TmpCounter = WritePointer-OldWritePointer;
    if(TmpCounter<0){
    TmpCounter+=LEN_CIRCULAR_BUF;
    }

    }


    Time2=TimeLineFun(1);
    //printf("T1=%d," ,Time2);

    Time3=TimeLineFun(2);

    CalculateParam();

    ReadPointer=ReadPointer+(CrossZero*ANALOG_NUM); //in every half_cycle ReadPointer increases the size of CrossZero*ANALOG_NUM
    Counter=Counter-(CrossZero*ANALOG_NUM); //in every half_cycle ReadPointer decreases the size of CrossZero*ANALOG_NUM


    if((ReadPointer)>=(LEN_CIRCULAR_BUF)) {
    ReadPointer=ReadPointer-LEN_CIRCULAR_BUF;
    //xil_printf(" ********ReadPointer=%d *********\n\r", ReadPointer);
    }
    Counter=0;*/

    }

    /** end *****/

    }

    /** @} */

    I set a breakpoint point for every function. Once it reached the log_init, the program got stuck in the error.

    I also comment out the log_init() function, then I debug the program. In this case, the program stays in the ble_stack_init() as you can see below.

    I have no idea about this.

    What do you think?

    Please guide me.

    Br,

    Sama

Related