This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

system-on-wakeup-on-rtc sleep code, why the current is 3mA?

The test code:

#include "nrf51.h"
int main(void) {
NRF_CLOCK->LFCLKSRC = 0UL;	// Internal 32kHz RC

// Start the 32 kHz clock, and wait for the start up to complete
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
NRF_CLOCK->TASKS_LFCLKSTART = 1;
while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);

// Configure the RTC to run at 2 second intervals, and make sure COMPARE0 generates an interrupt (this will be the wakeup source)
NRF_RTC1->PRESCALER = 0;
NRF_RTC1->EVTENSET = 0x1UL;
NRF_RTC1->INTENSET = 0x1UL;
NRF_RTC1->CC[0] = 10*32768;
NVIC_EnableIRQ(RTC1_IRQn);

        // Start the RTC timer
        NRF_RTC1->TASKS_START = 1;

            // Enter System ON sleep mode
            __WFE();
            // Make sure any pending events are cleared
            __SEV();
            __WFE();

        // Stop and clear the RTC timer
//	NRF_RTC1->TASKS_STOP = 1;
//	NRF_RTC1->TASKS_CLEAR = 1;
}

void RTC1_IRQHandler(void)
{
// This handler will be run after wakeup from system ON (RTC wakeup)
if(NRF_RTC1->EVENTS_COMPARE[0]) {
    NRF_RTC1->EVENTS_COMPARE[0] = 0;
    NRF_RTC1->TASKS_CLEAR = 1;
}
}

Any advice? datasheet says the RTC current should be 0.1uA....

Parents
  • still 3mA???

    code:

    #include "nrf51.h"

    int main(void) { NRF_CLOCK->LFCLKSRC = 0UL; // Internal 32kHz RC

    // Start the 32 kHz clock, and wait for the start up to complete
    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_LFCLKSTART = 1;
    while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);
    
    // Configure the RTC to run at 2 second intervals, and make sure COMPARE0 generates an interrupt (this will be the wakeup source)
    NRF_RTC1->PRESCALER = 0;
    NRF_RTC1->EVTENSET = 0x1UL;
    NRF_RTC1->INTENSET = 0x1UL;
    NRF_RTC1->CC[0] = 10*32768;
    NVIC_EnableIRQ(RTC1_IRQn);
    
            // Start the RTC timer
            NRF_RTC1->TASKS_START = 1;
    

    //SCB->SCR |= SCB_SCR_SEVONPEND_Msk; SCB->SCR |= 1UL<<4; while(1) { __WFE(); __SEV(); __WFE(); } }

  • Hi nan,

    have you solved your problem? I seem to have one you were having. The moment I start RTC, which has to be be on to wake up MCU, I get around 3mmA current.

    Cheers

    Adam

Reply Children
No Data
Related