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

  • 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