Hello.
I am using nrf52-dk with 52832 (PCA10040).
To check the current consumption, I made a simple test.
I need to wake up every 5 seconds, do what is needed and fall asleep again.
Since I need to wake up on a timer, I use "System ON" mode. In the example, the timer handler is empty.
#include "nrf.h"
#include "bsp.h"
#include "boards.h"
#include "app_error.h"
#include "nrf_drv_timer.h"
#define RAM_RETENTION_OFF (0x00000003UL) /**< The flag used to turn off RAM retention on nRF52. */
#define TIMER_MS (uint32_t)5000
const nrf_drv_timer_t work_timer = NRF_DRV_TIMER_INSTANCE(0);
void configure_ram_retention(void){
NRF_POWER->RAM[0].POWER = RAM_RETENTION_OFF;
NRF_POWER->RAM[1].POWER = RAM_RETENTION_OFF;
NRF_POWER->RAM[2].POWER = RAM_RETENTION_OFF;
NRF_POWER->RAM[3].POWER = RAM_RETENTION_OFF;
NRF_POWER->RAM[4].POWER = RAM_RETENTION_OFF;
NRF_POWER->RAM[5].POWER = RAM_RETENTION_OFF;
NRF_POWER->RAM[6].POWER = RAM_RETENTION_OFF;
NRF_POWER->RAM[7].POWER = RAM_RETENTION_OFF;
}
void timer_handler(nrf_timer_event_t event_type, void* p_context){
switch (event_type){
case NRF_TIMER_EVENT_COMPARE0:
break;
default:
//Do nothing.
break;
}
}
void init_timer(void){
uint32_t time_ticks;
nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
APP_ERROR_CHECK(nrf_drv_timer_init(&work_timer, &timer_cfg, timer_handler));
time_ticks = nrf_drv_timer_ms_to_ticks(&work_timer, TIMER_MS);
nrf_drv_timer_extended_compare(&work_timer, NRF_TIMER_CC_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
nrf_drv_timer_enable(&work_timer);
}
void clocks_start( void ){
NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK->TASKS_HFCLKSTART = 1;
while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);
}
int main(void)
{
clocks_start();
configure_ram_retention();
init_timer();
while (1) {
// Enter System ON sleep mode
__WFE();
__SEV();
__WFE();
}
}
The board was prepared according to the documentation: I cut SB9, soldered SB12.
Power supply - 3.3V. The debugger is not connected.
I measure the consumption with a multimeter (P22) and it is 0.68 mA, but there should be several uA.
What am I doing wrong?