I'm working on putting our system into low power idle mode. We use MyNewt to build our application. In order to get to the lowest power, I disabled BLE and all our drivers except UART for console and debug messages. We have a command that can shut off a bunch of stuff and call __WFE and __SEV(). The code is tested on a nrf52DK(PCA10040 1.2.4, 2018.23). I checked the current on P22 on the board and the measurement was 270uA @ 3.8V from external power supply. This is far away from what your data sheet described. I have checked the setting everywhere and can not figure out what else I need to turn off. Can you please provide some suggestion where I should check?
except UART for console and debug messages.
UART peripheral requires HFCLK and if you run HFCLK with the 64MHz crystal current consumption will be ~250uA.
Thanks for the info. It looks like my HFCLK is still up and running. One thing I didn't mentioned in my original post is I did disable UART before WFE. Is there a way to check which peripheral is still using HFCLK?
Could you try to stop the UART transmitter/receiver, before disabling it ?
NRF_UARTE0->TASKS_STOPRX = 1;
NRF_UARTE0->TASKS_STOPTX = 1;
Sorry for late reply. I was out of office. I already tried this. It didn't work. I still see the current is >270uA.
Any other suggestions?
I would like to share my test code here. FYI.
enter_sleep_mode_cb(struct os_event *ev)
power_mode_e state = *(power_mode_e *)ev->ev_arg;
if(state == POWER_STATE_NONE)
// overwrite the power state
// call hal power API
//1. put peripheral into sleep
// excluded all driver code for test
// Turn off UART/SPI/I2C
// uart is turned off here by os_dev_suspend_all
// turn off timer
// turn off GPIOE
//something new from mynewt
NRF_CLOCK->TASKS_HFCLKSTOP = 1;
//2. put CPU into wait for event mode
// Wait for an event
// clear the internal event register
//3. wake up process
// enable UART/SPI/I2C
//4. wake up complete
I have figured the root cause after I got some help from local FAE team. But, the solution is not clear now.
The SPIM1 actually prevent the system turning off HFXO. It came down to a function call we used in our driver. In MyNewt project, it offers several APIs to write/read the data via SPI. You can find the code here: https://github.com/apache/mynewt-core/blob/master/hw/mcu/nordic/nrf52xxx/src/hal_spi.c. One way is to write byte by byte and poll the status, “hal_spi_txrx()”. The other way is to leverage TASKS, “hal_spi_txrx_noblock()”. Still waiting for further information.
Got an answer for this one from FAE. I hit Erratum 89.
There is another post on the forum also point out the same thing.
After I applied the workaround, the current went down.