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 



  • Try setting a breakpoint at uart_init() in your main() function. Is it reached?

  • Hi Edvin, I try settting a breakpoint at uart_init() and here is the result

  • Looks like you are using app_timer in your application as well. app_timer is using RTC1, so you can't use that for the libuarte either. 

    The reason the log doesn't print anything is because it crashes before log_init(). Try to set log_init() first. 

    Since you only have 3 RTCs, and want to use 1 for the softdevice, 1 for the app_timer, you don't have 2 left to use for libuarte. However, if you look at the definition of NRF_LIBUARTE_ASYNC_DEFINE() in nrf_libuarte_async.h, you can see that if you set _rtc1_idx and _timer1_idx to NRF_LIBUARTE_PERIPHERAL_NOT_USED, then it will use the app_timer instead. Try that. 

    If you want to use the app_timer for the libuarte timer like this, then you need to make sure that the libuarte has a higher interrupt priority than the app_timer itself. Therefore, set:

    .int_prio   = APP_IRQ_PRIORITY_LOW_MID.

    Best regards,

    Edvin

  • Hi Edvin, thanks for your reply.  I'll try this
    When I move log_init() above uart_init()
    i got this problem 

  • That is the problem you had all along. The only difference is that you are now able to see what the problem is, because you moved it to after log_init(). Please see the details in my previous reply on how to fix the NRF_ERROR_INVALID_PARAM.

Reply
  • That is the problem you had all along. The only difference is that you are now able to see what the problem is, because you moved it to after log_init(). Please see the details in my previous reply on how to fix the NRF_ERROR_INVALID_PARAM.

Children
No Data
Related