Skip to main content

How to keep RTC working in Deep Sleep mode

DA14530 and DA14531

7 months ago

Posted by brent_zheng 197 points 12 replies
0 upvotes

Dear Sir,

  My product was using several times per day. So I want to put it into deep-sleep(RAM Off) and keep RTC counting once free.

  The problem is RTC calendar/time register was zero when system wakeup. I have already setup PD_TIM correctly.

  Could you please help me to solve this problem, thank you very much!

6 months ago

PM_Dialog

Hi brent_zheng,

Thanks for your question online. I would recommend first checking the proximity reporter project from the SDK6.0.14 and our “Sleep modes” tutorial. Link is provided below :

http://lpccs-docs.dialog-semiconductor.com/DA14531_Sleep_Mode+/deepsleep_config.html

DA14531 is able to wake up from deep sleep mode via the RTC. Check our step #9 :

To wake up using RTC (Real Time Clock) timer, define CFG_DEEP_SLEEP_WAKEUP_RTC and undefine the rest of the wake-up mechanism.

Let us know if you still have any issue.

Thanks, PM_Dialog

6 months ago

brent_zheng 197 points

Dear Sir,

 Thank you for your quickly answer. Yes I was using Prox-reporter project. When I defined CFG_DEEP_SLEEP_WAKEUP_RTC, the system can be wakeup in 10s later from Deep-sleep. But I question is how to keep RTC  calendar/time register after wakeup. I called rtc_get_time_bcd() and the return is zero after system wakeup from deep-sleep.

Thanks.

6 months ago

brent_zheng 197 points

Dear Sir,

The register data before go to deep-sleep:

PMU_CTRL_REG:0
CLK_RTCDIV_REG:40c8
RTC_CONTROL_REG:0
RTC_EVENT_FLAGS_REG:0
RTC_TIME_REG:80000001
RTC_CALENDAR_REG:a021010d
RTC_KEEP_RTC_REG:1

After wakeup from deep-sleep by RTC_INTR_MIN event :

PMU_CTRL_REG:2
CLK_RTCDIV_REG:0
RTC_CONTROL_REG:0
RTC_EVENT_FLAGS_REG:0
RTC_TIME_REG:0
RTC_CALENDAR_REG:0
RTC_KEEP_RTC_REG:0

It seems RTC was working durning deep-sleep, but some one clear or reset those register in wakeup procedure. Could you please help me check it?

Thanks. 

6 months ago

PM_Dialog

Hi brent_zheng,

Apologies for the delay. Let me check this and I'll get back to you ASAP.

Thanks, PM_Dialog

6 months ago

PM_Dialog

Hi brent_zheng,

If you would like to keep the RTC values when the DA14531 wakes-up, you should use the extended sleep mode.  In this mode, all the RAM blocks are retained (default configuration), so the registers are not reset.

When the DA14531 wakes up, the application code will start executing immediately and no data will be lost.

The SDK6.0.14.1114 provides 2 examples to understand how to use the extended sleep mode and how to wake-up the DA4531 too.

projects\target_apps\ble_examples\prox_reporter\Keil_5

projects\target_apps\ble_examples\ble_app_sleepmode\Keil_5

Thanks, PM_Dialog

6 months ago

brent_zheng 197 points

Dear Sir,

  Yes, I know extend sleep can be used. My concern is why RTC can work during deep-sleep, but cleared when wakeup? Because RAM did not be retained? I also tried deep-sleep with RAM retained, seems does not work.

BR,

Brent

accepted answer!

6 months ago

PM_Dialog

Hi brent_zheng,

Please check the arch_set_deep_sleep() API. After entering the deep sleep mode and the code reaches to WFI(), a HW reset should be performed on the wake-up. In line 122, the PMU_CTRL_REG[RESET_ON_WAKEUP] is set to 1, so an HW is activated on wake up according to DA14531 Datasheet (v3.3), section 5.2.1 POR, HW, and SW Reset

In Table 39: Reset Signals and Registers, the RTC regs are reset by POR or HW reset. So, from Deep sleep to wake-up mechanism goes through an HW reset process therefore it will copy software from OTP or the secondary memory. Due to this reason, ram data will be overwritten and RTC will start counting from zero again.

Thanks, PM_Dialog

6 months ago

brent_zheng 197 points

Ok, I've got it, thank you very much!

6 months ago

PM_Dialog

Hi brent_zheng,

Thanks for accepting my answer. If you have any follow up question, please raise a new forum ticket.

Thanks, PM_Dialog

4 months ago

Dear Support Team

 

My goal is to achieve customized timings of Deep Sleep Mode in my source code.

Before doing the same, I am trying to first implement the ble_button_wakeup project ; by using RTC based enable Interrupts.

The present status of the same is as below. 

1.) The flow is Enabling RTC Interrupt, Defining Interrupt handler, Waking up the device when interrupt handler calls

2.)  We finished Enabling RTC interrupt, able to receive the interrupt and calling the wake up function using interrupt handler. But the device is not waking up

3.) Basically, In termite, I am able to see the timer running for 10 seconds and then sleep mode ON message, but the device won't wake based on RTC Enable Interrupt.

I have attached an important part of the code for your assessment, please let me know if I am missing something, here.

 

Code Part: For RTC Enable Interrupt

 

void initialize_alarm(rtc_time_t time)

{

  rtc_time_t alarm_time;

 

alarm_time = time;

alarm_time.sec += RTC_TIMEOUT;

 

rtc_set_alarm(&alarm_time, NULL, RTC_ALARM_EN_SEC);

 

// Clear pending interrupts

rtc_get_event_flags();

rtc_register_intr(rtc_interrupt_hdlr, RTC_INTR_ALRM);

}

 

 Code Part: Interrupt handler

static void rtc_interrupt_hdlr(uint8_t event)

{

   //Stub function

rtc_wake_flag = 1;

}

if(rtc_wake_flag) //sleep mode OFF after timer reaches 10s 

{

printf_string(UART2,"sleep mode off\n");

sprintf(time,"\nT:%d:%d:%d\n\r",mytime.hour,mytime.minute,mytime.sec);

printf_string(UART2,time);

rtc_wake_flag=0;

arch_set_sleep_mode(ARCH_SLEEP_OFF);    // Disable sleep mode

arch_ble_force_wakeup();                // Force the BLE to wake up

arch_ble_ext_wakeup_off();              // Disable the permanent sleep flag

    app_easy_wakeup();                      // Invoke corresponding actions as soon as the BLE is awake 

user_app_init();

}

 

Your Inputs and directions, wil be helpful towards  speedy prototyping of our projects. Looking forward to your valuable suggestions.

3 months ago

Dear Team

Can You please reply to my above, have been waiting since long time. 

Thank You

Warm Regards
Basu.B.Patil

3 months ago

PM_Dialog

Hi Bas321,

Thanks for your comment on the forum. I would suggest to take a look at the pxp_reporter example of the SDK.

When CFG_EXT_SLEEP_WAKEUP_RTC or CFG_DEEP_SLEEP_WAKEUP_RTC, the DA14531 wakes up from extended sleep or deep sleep accordingly.

The configure_rtc_wakeup() configures the RTC as wake-up source and so the chips wakes up after 10 seconds (alarm_time.sec += 10).

Before going to sleep, you should ensure that the PD_TIM is open. Please check app_advertise_complete().

As soon as the device takes an RTC interrupt, the rtc_interrupt_hdlr() is excecated in order to resume from sleep and wake up. The rtc_interrupt_hdlr() should be registered in rtc_register_intr().

Thanks, PM_Dialog