DeepSleep on MIMXRT685-AUD-EVK with RTC as wake up source

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DeepSleep on MIMXRT685-AUD-EVK with RTC as wake up source

966 Views
lambertarthur22
Contributor I

Hi,

I am currently trying to implement a POC on the MIMXRT685-AUD-EVK

I need to use deep sleep mode on the M33 side and RTC as a wake-up source.

I have a working example with alarm API and using seconds:

RTC_Init(RTC);
RTC_Reset(RTC);

// Enable RTC wake
EnableIRQ(RTC_IRQn);
EnableDeepSleepIRQ(RTC_IRQn);

RTC_EnableTimer(RTC, false);

RTC_EnableInterrupts(RTC, kRTC_AlarmInterruptEnable);
RTC_EnableTimer(RTC, true);

RTC->MATCH = RTC->COUNT + 20; // lets wake up in 20 seconds

BOARD_EnterDeepSleep(APP_EXCLUDE_FROM_DEEPSLEEP);

But I would like to use a millisecond delay! I did not find any examples in the SDK. There is some code available here: AN12801.pdf. Also here: hardware timer. But no success so far. A lot of deprecated APIs in the example and not the same APIs.

My failed attempt: 

RTC_Init(RTC);
RTC_Reset(RTC);

/* RTC time counter has to be stopped before setting the date & time in the TSR register */
RTC_EnableTimer(RTC, false);

RTC_EnableInterrupts(RTC, RTC_CTRL_WAKE1KHZ_MASK);
RTC_EnableWakeUpTimerInterruptFromDPD(RTC, true);
EnableDeepSleepIRQ(RTC_IRQn);

RTC_EnableTimer(RTC, true);
RTC->CTRL |= RTC_CTRL_RTC_SUBSEC_ENA_MASK;
RTC->COUNT = 0;

// add 200  ms seconds
RTC_SetWakeupCount(RTC, 200);

BOARD_EnterDeepSleep(APP_EXCLUDE_FROM_DEEPSLEEP);

 

Thanks,

 

Labels (1)
0 Kudos
Reply
5 Replies

938 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @lambertarthur22 

Recommend to use MCUXpresso configure tool to config, then refer to the generated code:

Alice_Yang_0-1672214728245.png

 

 

BR

Alice

 

0 Kudos
Reply

922 Views
lambertarthur22
Contributor I

Hello Alice,

Thanks for the reply.

Ok so I configure my tool to wake up from deep sleep using RTC with a 6ms delay.

I check wake up time, put 6 in wake up time textbox, check enable wake up in deep power down. I check Enable interrupt. I finally select Enabled in initialization.

The generated code from peripherals.c/.h:

static void RTC_init(void) {
/* RTC initialization */
RTC_Init(RTC_PERIPHERAL);
/* Wake-up initialization */
RTC_SetWakeupCount(RTC_PERIPHERAL, RTC_WAKE_UP_TIME);
/* Enable interrupts for deep power-down */
RTC_EnableInterrupts(RTC_PERIPHERAL, kRTC_WakeupInterruptEnable);
/* Enable interrupt RTC_IRQn request in the NVIC. */
EnableIRQ(RTC_IRQN);
}

/***********************************************************************************************************************
* Initialization functions
**********************************************************************************************************************/
void BOARD_InitPeripherals(void)
{
/* Initialize components */
RTC_init();
}

In my main I put:

(...)

BOARD_InitPeripherals ();

PRINTF("Go to Deep Sleep... \r\n");
BOARD_SetPmicVoltageBeforeDeepSleep();
BOARD_EnterDeepSleep(APP_EXCLUDE_FROM_DEEPSLEEP);
BOARD_RestorePmicVoltageAfterDeepSleep();
PRINTF("Wake up M33... \r\n");
delay(); delay(); delay();
PRINTF("Lets go... \r\n");



Nothing happens... I tried to add RTC_EnableTimer(RTC, true) after the Init peripheral call but this is not working either. No wake up.



Thanks,

Arthur.

0 Kudos
Reply

844 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @lambertarthur22 

About low power and wakeup, recommend you first have a look at the power_manager demo under SDK, and "5.3.5 Deep power-down mode and full deep power-down mode"  in UM . Then add RTC into Power_manager demo, first confirm RTC works well, then check whether can wake up. 

 

BR

Alice

0 Kudos
Reply

833 Views
lambertarthur22
Contributor I

Hello Alice,

This is precisely what I have already done. I clone the power manager project demonstrating the power mode. This time I am working directly inside the original power manager project.

Nothing is working. I even cannot have the alarm example working using the Config Tools. I made it work by writing some code in the first post. If I use the generated code through the Config tool, this is not working anymore. When I read the header, I can see that the tool is still generating deprecated API.

For example, I configure the Config tool to use an alarm RTC. This is my home config tool page :

config_tool_homePNG.PNG

 

This is my alarm configuration. I configure the tool to set an alarm 59 seconds after the boot.

 

alarm_setting.PNG

 

I push the Update code button. I added the init peripheral function generated by the tool:

 

diff --git a/mimxrt685audevk_power_manager/source/power_manager.c b/mimxrt685audevk_power_manager/source/power_manager.c
index 5bf779b..89be1c3 100644
--- a/mimxrt685audevk_power_manager/source/power_manager.c
+++ b/mimxrt685audevk_power_manager/source/power_manager.c
@@ -15,6 +15,7 @@
#include "fsl_pint.h"
#include "fsl_usart.h"
#include "pmic_support.h"
+#include "peripherals.h"

#include "fsl_pca9420.h"
/*******************************************************************************
@@ -160,6 +161,7 @@ int main(void)
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitDebugConsole();
+ BOARD_InitBootPeripherals();

I can see in the RTC_init generated code that there is an RTC_StopTimer(RTC_PERIPHERAL) call.

So I suppose that I have to add a RTC_StartTimer(RTC_PERIPHERAL); before calling the code to switch to sleep mode. 

My change in power_manager.c:

@@ -205,9 +207,11 @@ int main(void)
switch (gCurrentPowerMode)
{
case kPmu_Sleep: /* Enter sleep mode. */
+ RTC_EnableTimer(RTC, true);
POWER_EnterSleep();
break;
case kPmu_Deep_Sleep: /* Enter deep sleep mode. */
+ RTC_EnableTimer(RTC, true);
BOARD_SetPmicVoltageBeforeDeepSleep();
#if POWER_DOWN_PLL_BEFORE_DEEP_SLEEP
/* Disable Pll before enter deep sleep mode */

I am running the test with Sleep mode and Deep sleep mode. I never wake up. The user button is working to wake-up the board.

Thanks,

Arthur.

0 Kudos
Reply

810 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @lambertarthur22 

Refer to the steps in UM , check generated code.

Alice_Yang_1-1673340961244.png

 

BR

Alice

 

 

0 Kudos
Reply