Hi! We're developing on an nrf52840dk and have been running in to some problems when we want the system to only pull currents in the size of a few microamps. As our system enters a low-power mode it shuts down all initiated peripherals. However for the UART there seems to be a problem when we uninitiate the peripheral. In our function a register write is done to ENABLE through nrf_uarte_disable:
__STATIC_INLINE void nrf_uarte_disable(NRF_UARTE_Type * p_reg)
{
p_reg->ENABLE = UARTE_ENABLE_ENABLE_Disabled;
}
Even though the uart-instance is removed and no longer able to send/receive data the measured current is around 1 mA above what it should be; something is still running when it shouldn't be. One suggested solution is to further write on the register, more specifically to stop transmitting and receiving (TASK_STOPRX and TASK_STOPTX). We tried to add this before nrf_uarte_disable through:
nrf_uarte_event_clear(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXSTOPPED);
nrf_uarte_task_trigger(nordic_nrf5_uart_register[instance], NRF_UARTE_TASK_STOPTX);
nrf_uarte_task_trigger(nordic_nrf5_uart_register[instance], NRF_UARTE_TASK_STOPRX);
while (!nrf_uarte_event_check(nordic_nrf5_uart_register[instance], NRF_UARTE_EVENT_TXSTOPPED)){}
These function calls are based on the functions nrfx_uarte_tx_abort() and nrfx_uarte_rx_abort() where these calls are made. However this doesn't seem to solve the issue as the current still remains relatively high.
After further investigations we found that the radio peripheral contains a POWER-register at a certain offset (0xFFC) from the base adress which resets the entire register of the peripheral by first setting it to 0 and then 1.
However this register is not defined for any other peripheral than the radio in the datasheet/manual for the nRF52840 but we tried anyway to see if it was possible to do the same kind of reset for the serial as the radio. The UART we used had the base adress 0x40028000 and the register we wrote to was therefore 0x40028FFC. Writing 0 and then 1 on this position in the memory seemed to solve the problem as the drawn current dropped to a more reasonable value.
It solves the problem but it includes writing to a "hidden" register, why is this working and is there any other way to work around this problem other than these methods?