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

How to turn off completely UART in nRF52840

Hello, I’m using nRF52840 with SDK 16 and SD 7. My purpose is to save as much power is possible using high-frequency clock (32MHz) only during periodic duties and BLE activity and low-frequency clock (32KHz crystal) otherwise. I’ve programmed app-timer and app-scheduler: if I use only I/O the sleep time power consumption is about 3uA. If I power-on UART with FIFO all the time, power consumption is about 1mA. So I need to power UART only when code uses it in app-scheduler event handler: I invoke app_uart_init() and app_uart_close() after few milliseconds every 1s, but unfortunately the power consumption is 1mA all the time. Apparently, app_uart_close() doesn’t power-off the UART; I follow various post in this blog with no success.

Thank you

Elisa

Parents
  • Hi Elisa,

    I had similar problem when working with nrf52811. I was using SDK 15.3 and I was testing this on nRF52840, so it should also work for you. 
    https://devzone.nordicsemi.com/f/nordic-q-a/58745/uart-disable-problem
    Check the verified answer. 

    Best regards,
    Vojislav.

  • Thank you Vojislav, but it’s not the same case. I don’t power on/off the UART in BLE events, but in a similar way in a callback invoked by app-scheduler and the scheduled event is generated by an app-timer periodic callback:

     

    /**@brief Periodic handler function to be called by the scheduler. */

    void periodic_scheduler_event_handler(void *p_event_data, uint16_t event_size)

    {

        char string[] = {'\0', '\0', ':', '\0'};

        nrf_gpio_pin_toggle(LED_1);

            

        byteToHex(counter, string);

        uart_init();

        app_uart_putstr(string, 4);

        app_uart_close();

           

        counter++;

    }

     

    /**@brief Timeout handler for the repeated timer used for toggling LED 1.

    *

    * @details Print a log line indicating weather executing in thread/main or interrupt mode.

    */

    static void timer_handler(void * p_context)

    {

        app_sched_event_put(NULL, 0, periodic_scheduler_event_handler);

    }

     

    I still need a feedback.

Reply
  • Thank you Vojislav, but it’s not the same case. I don’t power on/off the UART in BLE events, but in a similar way in a callback invoked by app-scheduler and the scheduled event is generated by an app-timer periodic callback:

     

    /**@brief Periodic handler function to be called by the scheduler. */

    void periodic_scheduler_event_handler(void *p_event_data, uint16_t event_size)

    {

        char string[] = {'\0', '\0', ':', '\0'};

        nrf_gpio_pin_toggle(LED_1);

            

        byteToHex(counter, string);

        uart_init();

        app_uart_putstr(string, 4);

        app_uart_close();

           

        counter++;

    }

     

    /**@brief Timeout handler for the repeated timer used for toggling LED 1.

    *

    * @details Print a log line indicating weather executing in thread/main or interrupt mode.

    */

    static void timer_handler(void * p_context)

    {

        app_sched_event_put(NULL, 0, periodic_scheduler_event_handler);

    }

     

    I still need a feedback.

Children
Related