Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

UART Data byte corrupt when calling nrf_pwr_mgmt_run(); in main while loop.

I am using nRF52805(SDK 17.0.1 & S112) in my application development. Designed GATT Table Having some custom services with read, write & notify properties, And also, there is some data communication in between nRF52805 & Host Microcontroller via UART interface(libUARTE is used for handling all communication) for updating custom characteristics, I need to do power optimization as device is battery operated, so power management is initialized by "power_management_init();" function & everything working fine until I'm calling nrf_pwr_mgmt_run(); in main while loop . But upon calling "nrf_pwr_mgmt_run();"  some UART data byte got corrupted (I'm suspecting) & some times application gets stuck(may be goes into unknown/unrecoverable state). Also, I'm suspecting some kind of event time handling issue between softdevice & application interrupts.

My question is below:

  1. is there any limitation of using libUARTE in Power Management mode.
  2. I also tried app_uart for my application and facing same kind of issue, so is there any better way to handle heavy transection of data on UART having ble stack enabled.
  3. In power management (when calling nrf_pwr_mgmt_run();) need some specific setting to reduce current consumption & How it is working in real scenario.  

please suggest me for above points.

Thanks.

  • Hi

    I'm not sure I understand. Do you try running the libUARTE peripheral when you have called the nrf_pwr_mgmt_run() function? This will likely not work. The recommended approach is to uninitialize the driver and then call the nrf_pwr_mgmt_run() function to go into idle mode either for a set amount of time or until it is woken up by an external event. Then you can reinitialize it once the device wakes up.

    Best regards,

    Simon

  • thanks for reply Simonr.

    Yes, I'm using libUARTE peripheral and also calling nrf_pwr_mgmt_run(). for reducing current consumption. As I understood, I need to follow below steps in main while(1) loop?

    1. uninitialize libUARTE peripheral by calling "nrf_libuarte_async_uninit()".
    2. call " nrf_pwr_mgmt_run()"
    3. again, initialize libUARTE peripheral by calling "nrf_libuarte_async_init()".

    Also in that case, What will be the wake up(external event) source, do I need to configure it?

  • Hi

    As you can see, the nrf_pwr_mgmt_run() function (in nrf_pwr_mgmt.c) prepares the device for sleep, and goes into a mode where it waits for an event to wake it up. So whenever an event occurs on the nRF52 it will wake back up and you can initialize the libUARTE and resume operations. Some of the (most common) wake up options are as follows: You can set a timer to trig an event after X amount of time or you can have a physical button if you want to wake it up manually.

    Best regards,
    Simon

  • Hi, I don't have any physical button interface for wake-up (as device is not directly accessible to user). And also i need to remain in system on state always, because user can connect at any time. Although , I need to get BLE current consumption with in 300- 400 uA. so,Is there any way to reduce the current consumption without setting up wakeup source  & and also capable of tx/rx data on UART within sleep mode. This is the requirement of my application.

    please suggest.

    Thanks 

  • Hi

    I guess the nRF52805 will be advertising, and scanning devices will be able to connect to it when they see it, correct? That part should be doable if you keep it in sleep and wake it up every second or two seconds to advertise for a short amount of time before going back to sleep. Keeping the UART always on might be a bit harder though, as the UART itself runs at ~400µA when turned on. I think you would have to let the UART sleep as well and only use the UART sometimes.

    Best regards,

    Simon

Related