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.

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

  • Thanks for reply. I'm doing same as you suggested, means in advertising mode only, I'm calling "nrf_pwr_mgmt()" function .As soon as central gets connected with device, I stop calling "nrf_pwr_mgmt()" function. And in that case UART is running properly without any data loss. Also I set advertisement duration 1000ms but still current consumption is too high(450 uA at the time of advertising). 

    So, my question is:

    1. Is there any other specific settings needs to take CPU in sleep mode apart from calling "nrf_pwr_mgmt()" function.
    2. How to handle current consumption in advertising mode as in my case it's too much on 1000ms interval, is there any specific setting required?
    3. How to handle UART communication in sleep mode.
  • Hi

    1 & 2. If you see ~400µA while the device is sleeping, that points to a peripheral, like the UART for example, still running. One fix to deal with this is to power cycle the UART as below for example. But it should be sufficient to make sure that the UART is finished operating before calling nrf_pwr_mgmt() by waiting for a UART TX/RX COMPLETE event(this is recommended).

    //Power cycle UART0:
    *(volatile uint32_t *)0x40002FFC = 0;
    *(volatile uint32_t *)0x40002FFC;
    *(volatile uint32_t *)0x40002FFC = 1;

    3. The device will wake up on any event, correct. So if that event is from the UART device it should wake up, and be ready to go pretty quick. Retransmissions from the UART device that is connected should be implemented to make sure they are received correctly.

    Best regards,

    Simon

  • thanks for reply Simonor,

    I am calling above suggested piece of code as shown below.

    //Power cycle UART0:
    *(volatile uint32_t *)0x40002FFC = 0;
    nrf_pwr_mgmt_run();
    *(volatile uint32_t *)0x40002FFC;
    *(volatile uint32_t *)0x40002FFC = 1;

    so,it will give power cycle to UART peripheral and in that case ,the peripheral and its registers
    will be reset to its initial state by switching the peripheral off and then back on again. As mentioned in document.

    So, after walkup my UART not working(may be UART remains off), may be because all its settings was cleared at power cycle.

    my question is here, still there something I'm missing in calling sequence or in some settings?    

  • Yes, after power cycling the UART you will need to reinitialize the UART again afterwards.

    Best regards,

    Simon

Reply Children
Related