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 



  • Pham Tam said:
    But after merged 2 examples I cannot find my DEVICE_NAME (but code was flashed successfully)

    So what you are saying is that your device is probably not advertising, right?

    My first guess is that one of the APP_ERROR_CHECK(err_code) receives an error. 

    Do you see the log from your application running on the nRF? It should print "Debug logging for UART over RTT started." when your application starts up (from your main() function). If you don't see it have you tried running a debug session in SES? If you still don't see any logs, try setting NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED to 0 in your sdk_config.h file and see if the log pops up then.

    Best regards,

    Edvin

  • Hi Edvin,

    Do you see the log from your application running on the nRF? It should print "Debug logging for UART over RTT started."

    No, I don't. In Debug Terminal there is nothing

    NRF_FPRINTF_FLAG_AUTOMATIC_CR_ON_LF_ENABLED to 0 in your sdk_config.h

    I try to set to 0 but nothing change
    When I click play button, The first time, I can't  play. The button not turn to red color || (playing) it's still |>  (green, ready to play). Probably somewhere error? And the second time I click, I can play, the button turn to red color || (playing).

    If I change my main.c into only ble_app_uart => this code will work, but I add libuartes it not advertising

  • Hi Edvin, I try to run standalone libuartes in this project. And I get this error

  • Hi Edvin, 
    My problem was solved. I used this sdk_config.h. And change  the timer_idx into 1. Seem BLE using timer_idx 0   ??
    if I use libuarte   NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 0, 0, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);

    I got problem like right before question.6082.sdk_config.h

  • Yes. Both TIMER0 and RTC0 are used by the softdevice (BLE stack). 

Reply Children
  • Hi Edvin, how to enable 2 libuartes in BLE&Libuartes project./

    I dont use TIMER0 and RTC0 but the code not worked..I can't debug. 

  • What happens when you try it like that? Does it compile? Do you get an error during runtime? What do you observe?

  • I can flashing code to nRF

    Debug Terminal didn'n show anything ( play button(excution) in debug mode can't play)

    Can't advertising 

    Can't communicate via libuarte

    But when I disable libuarte2. The code worked correctly.

  • Are you running this on an nRF52833 DK? If so, can you please .zip the application folder and upload it here?

    Best regards,

    Edvin

  • I am using custom board with chip nRF52833. 
    The pca is pca10100.
    I think problem is related to RTC and TIMER.
    Here is my project

    this is the relevant configuration:

    #define NRF_LIBUARTE_ASYNC_WITH_APP_TIMER 1
    #define NRF_LIBUARTE_DRV_UARTE0 1
    #define NRF_LIBUARTE_DRV_UARTE1 1

    #define NRFX_RTC_ENABLED 1
    #define NRFX_RTC0_ENABLED 1
    #define NRFX_RTC1_ENABLED 0
    #define NRFX_RTC2_ENABLED 1

    #define NRFX_TIMER_ENABLED 1
    #define NRFX_TIMER0_ENABLED 1
    #define NRFX_TIMER1_ENABLED 1
    #define NRFX_TIMER2_ENABLED 1
    #define NRFX_TIMER3_ENABLED 1
    #define NRFX_TIMER4_ENABLED 0

    NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 1, 1, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);
    NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 1, 2, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);
    here is my debug terminal


    ble_libuarte_tam.rar

Related