This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Use libuarte together with SoftDevice

Hello, guys.

We want to use libuarte - advanced UARTE driver in our current application developed for nRF52840 with SDK 17.0.2.

We can successfully run libuarte example located under \examples\peripheral\libuarte. However, the trouble comes when we want to merge this example in an environment that uses SoftDevice and app_timer modules.

I noticed that other people faced similar issues as well (thread). 

What would be the best way to merge libuarte into environment that uses SoftDevice and app_timer?

I noticed that libuarte example uses the following drivers:

      <file file_name="../../../../../../components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c" />
      <file file_name="../../../../../../components/drivers_nrf/nrf_soc_nosd/nrf_soc.c" />

Those drivers are for the case when SoftDevice is not present. In the presence of SoftDevice, what should we use?

I used 

<file file_name="../../../../../../components/softdevice/common/nrf_sdh_soc.c" />
 as a replacement for nrf_soc.c but I am not sure what should I put for the nrf_nvic.c replacement. Can you help me with this?

When I merge libuarte example into my environment that contains SoftDevice and app_timer modules, and use Timer 2 and RTC 2 for NRF_LIBUARTE_ASYNC_DEFINE:

NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 2, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);

nrf_libuarte_async_init() function returns error code 7 which should be NRF_ERROR_INVALID_PARAM according to nrf_error.h file.

Do you have any idea what I am doing wrong?

In this thread, there is a mention that NRFX_PRS_BOX_4 should be set to disabled. Does that impliy the following content into sdk_config.h file:

#ifndef NRFX_PRS_BOX_4_ENABLED
#define NRFX_PRS_BOX_4_ENABLED 0
#endif

Thanks in advance for your time and efforts.

Cheers,

Bojan.

Parents
  • Hey, guys!

    Just wanted to share with you that I was finally able to merge libuarte example into the application that contains SoftDevice and app_timer.

    Given that fact that SoftDevice requires RTC0 and Timer0 and app_timer library consumes RTC1, I used RTC2 and Timer2 for libuarte implementation:

    NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 2, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);

    The numbers 2, 2 in the above line of code mean RTC2 and Timer2 are taken for libuarte. At the same time, you should have enabled those ressources (RTC2, Timer2) through the sdk_config.h file.

    Also, I removed everything related to UART from sdk_config.h file and included drivers from libuarte example:

    Finally,

          <file file_name="../../../../../../components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c" />
          <file file_name="../../../../../../components/drivers_nrf/nrf_soc_nosd/nrf_soc.c" />
    lines should be replaced with:

          <file file_name="../../../../../../components/softdevice/common/nrf_sdh.c" />
          <file file_name="../../../../../../components/softdevice/common/nrf_sdh_soc.c" />

    I did not touch NRFX_PRS_BOX_4 from sdk_config.h file even if it was suggested in this thread.

    Cheers!

    Bojan.

Reply
  • Hey, guys!

    Just wanted to share with you that I was finally able to merge libuarte example into the application that contains SoftDevice and app_timer.

    Given that fact that SoftDevice requires RTC0 and Timer0 and app_timer library consumes RTC1, I used RTC2 and Timer2 for libuarte implementation:

    NRF_LIBUARTE_ASYNC_DEFINE(libuarte, 0, 2, 2, NRF_LIBUARTE_PERIPHERAL_NOT_USED, 255, 3);

    The numbers 2, 2 in the above line of code mean RTC2 and Timer2 are taken for libuarte. At the same time, you should have enabled those ressources (RTC2, Timer2) through the sdk_config.h file.

    Also, I removed everything related to UART from sdk_config.h file and included drivers from libuarte example:

    Finally,

          <file file_name="../../../../../../components/drivers_nrf/nrf_soc_nosd/nrf_nvic.c" />
          <file file_name="../../../../../../components/drivers_nrf/nrf_soc_nosd/nrf_soc.c" />
    lines should be replaced with:

          <file file_name="../../../../../../components/softdevice/common/nrf_sdh.c" />
          <file file_name="../../../../../../components/softdevice/common/nrf_sdh_soc.c" />

    I did not touch NRFX_PRS_BOX_4 from sdk_config.h file even if it was suggested in this thread.

    Cheers!

    Bojan.

Children
Related