I'm working with a custom board that is using a nrf53840. The SDK is 16.0 and SoftDevice S140 version 7.0.1. Programming with SES. The board has various devices such as accelerometers, temperature, etc... communicating with the 52840 via SPI, I2C, and I2S. Because my principle application uses DFU and BLE, a secure boot loader and the Softdevice reside in memory. Neither are used in the current discussion.
I want to measure the quiescent current. I'm using an Otii to measure the current consumption.
main:
#include "si7210_thing/si7210_twi.h"
int main(void)
{
uint32_t err_code;
uint8_t id_value;
//si7210_twi_sleep();
//si7210_twi_master_init();
//si7210_twi_put_to_sleep_no_measure();
//si7210_twi_master_uninit();
//NRF_CLOCK->TASKS_HFCLKSTOP = 1;
NRF_POWER->SYSTEMOFF = 1;
for (; ; )
{
__WFE();
}
}
With the TWI peripheral's functions commented out, the board is consuming 113uA in systemoff. That indicates the peripheral devices are consuming power and need to be initialized and put to sleep.
So I start with the Si7210 which communicates with the nrf53840 via TWI. As you can see in the code, I've tried a couple of things. My first effort used the single function si7210_twi_sleep. When that had power issues, I thought to break its functionality up into three functions and test the power consumption when completing separate tasks.
I can use the functions si7210_twi_master_init and si7210_twi_master_uninit by themselves and do no TWI communications. When I do that the board's current consumption remains the same at 113uA as expected. When I use the function si7210_twi_put_to_sleep_no_measure, the board consumes 633uA in sleep mode. That function does two rx and two tx to configure two registers with appropriate values to put the si7210 completely asleep. From researching the devzone, I've concluded that the extra 520uA is because the HF clock is running.
It seems that any use of nrf_drv_twi_tx or nrf_drv_twi_rx triggers the HF clock but simply using nrf_drv_twi_uninit doesn't shut it down.
My question is how do I use a peripheral like TWI or SPI or I2S and then shut it down so that all the resources the peripheral was using are also stopped ?