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

  • Update:

    I followed the lines of the app error weak file and found out that when the program reaches the line: switch (id) and I press the play button it jumps to line 100 (NRF_BREAKPOINT_COND).

    I tried some suggestion in the devzone, including 

    https://devzone.nordicsemi.com/f/nordic-q-a/64963/app_error_fault_handler-id-0x00004001-pc-0x0003290b-app_error_handler-sdk-v17-nrf2840-pdk

    https://devzone.nordicsemi.com/f/nordic-q-a/65483/softdevice-assertion-failed-after-using-fds_gc/267757#267757

    I also edit the section placement macro as below due to SoftDevice present. However, it does not make a difference.

    FLASH_PH_START=0x0

    FLASH_PH_SIZE=0x100000

    RAM_PH_START=0x20000000

    RAM_PH_SIZE=0x40000

    FLASH_START=0x27000

    FLASH_SIZE=0xd9000

    RAM_START=0x20002ae8

    RAM_SIZE=0x3d518

    I could not find a solution.

    Please help.

    I look forward to hearing from you.

    Thanks 

    Sama,

  • Hi,

    BLE applications requires a certain method when debugging them. You can't resume an application after you have halted it. You'll have to restart it instead. It's explained more in detail here.

    Can you use this method and see how far the program reaches this time?

    regards

    Jared

  • Hi,

    Thank you for your reply. 

    Sorry, but It is not mentioned where should I change the PRIMASK bit in my registers list. 

    As I found out a CPU register containing this bit, but which register and which bit has been assigned?

    I wonder why important details do not explain anywhere. It is really time-consuming to find these details.

    I look forward to hearing from you.

    Thanks,

    Sama

  • Hi,

    I added the following code to set PRIMASK bit, as suggested in this post (https://devzone.nordicsemi.com/f/nordic-q-a/477/can-i-debug-ble-program)

    But this does not make any difference as you can see.

    When I select the first line in the active call frame on the top page as below

    It jumps in this part.

    Is there any clue to find the problem?

    Br,

    Sama

  • Hello! Sama:

    I think your code is okay.

    Your code is trap in error handle function.Because of sleep mode is running when your advertising timeout during debug mode. The real board without USB J-Link will be not halt in break-point. And the system will be reset when you wake up by external GPIO. It's the normal case in BLE UART example.

    static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
    {
    uint32_t err_code;

    switch (ble_adv_evt)
    {
    case BLE_ADV_EVT_FAST:
    err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
    APP_ERROR_CHECK(err_code);
    break;
    case BLE_ADV_EVT_IDLE:
    sleep_mode_enter();  //If you want to try prevent halt in debug mode....Change this function with normal mode or else.
    break;
    default:
    break;
    }
    }

Reply
  • Hello! Sama:

    I think your code is okay.

    Your code is trap in error handle function.Because of sleep mode is running when your advertising timeout during debug mode. The real board without USB J-Link will be not halt in break-point. And the system will be reset when you wake up by external GPIO. It's the normal case in BLE UART example.

    static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
    {
    uint32_t err_code;

    switch (ble_adv_evt)
    {
    case BLE_ADV_EVT_FAST:
    err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
    APP_ERROR_CHECK(err_code);
    break;
    case BLE_ADV_EVT_IDLE:
    sleep_mode_enter();  //If you want to try prevent halt in debug mode....Change this function with normal mode or else.
    break;
    default:
    break;
    }
    }

Children
Related