Greeting,
We are in process of upgrading from sdk1.1.0 to sdk 1.3.0.
In order to use less current, we have to enable and disable uarts during program exectution:
Our code this far has been as follows:
void uart_0_disable(void)
{
uart_0_is_enabled = false;
// stop tx and rx
NRF_UARTE0->TASKS_STOPTX = 1;
NRF_UARTE0->TASKS_STOPRX = 1;
// disable whole UART 0 interface
NRF_UARTE0->ENABLE = 0;
// deselect rx and tx pins and clear them
NRF_UARTE0->PSEL.TXD = 0xFFFFFFFF;
NRF_P0_NS->OUTCLR = (1 << PIN_UART_0_TX);
NRF_UARTE0->PSEL.RXD = 0xFFFFFFFF;
NRF_P0_NS->OUTCLR = (1 << PIN_UART_0_RX);
// reconfigure them as GPIO pins and set them to output/0
gpio_pin_configure(gpio_dev, PIN_UART_0_RX, GPIO_DIR_OUT);
gpio_pin_write(gpio_dev, PIN_UART_0_RX, 0);
gpio_pin_configure(gpio_dev, PIN_UART_0_TX, GPIO_DIR_OUT);
gpio_pin_write(gpio_dev, PIN_UART_0_TX, 0);
}
void uart_0_enable(void)
{
uart_0_is_enabled = true;
// select pins
NRF_UARTE0->PSEL.TXD = PIN_UART_0_TX;
NRF_UARTE0->PSEL.RXD = PIN_UART_0_RX;
// enable interface
NRF_UARTE0->ENABLE = 8;
NRF_UARTE0->TASKS_STARTRX = 1;
NRF_UARTE0->TASKS_STARTTX = 1;
}With this code, afer uart is disabled, we see a cca 680 μA power consumption drop.
With sdk v1.3.0 (and thus also new zephyr version), this code still runs (i.e. does not crash) and disables uart (LOG_INF after disable does nothing), but there is no drop in power consumption.
I have also tried using the new power management api:
void uart_0_disable(void)
{
struct device *uart0_dev = device_get_binding("UART_0");
device_set_power_state(uart0_dev, DEVICE_PM_OFF_STATE, NULL, NULL);
gpio_pin_configure(gpio_dev, PIN_UART_0_RX, GPIO_OUTPUT);
gpio_pin_set(gpio_dev, PIN_UART_0_RX, 0);
gpio_pin_configure(gpio_dev, PIN_UART_0_TX, GPIO_OUTPUT);
gpio_pin_set(gpio_dev, PIN_UART_0_TX, 0);
}
void uart_0_enable(void)
{
struct device *uart0_dev = device_get_binding("UART_0");
device_set_power_state(uart0_dev, DEVICE_PM_ACTIVE_STATE, NULL, NULL);
}
But the result is the same (aka printing gets disabled, but no consumption drop).
I ask if anything has changed regarding this and if so, how is this to be done now?
Regards,
Tjaž