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,

  • 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.

  • 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.

    Thanks for your reply Edvin,
    I followed this suggestion and it worked  ^^
    Can you explain for me the reson why we has to set libuarte's higher interrupt priority than the app_timer.?


     And this one

    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. 

    I try to set like that but when I debug I still got the same problem. I don't know why ?
    Having said that, I completed my main functions of my application. Thank Edvin for your supports in long day. Thank you so much, Edvin. I hope this thread will be useful for another one who got the same problem like me.

Related