Problem delay RTC wakeup

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

Problem delay RTC wakeup

1,772 Views
danielecortella
Contributor V


Hello,

i'm using the KL46 with KDS3.2 and SDK1.3.

I use the rtc to wakeup the micro every 4 minute and 30sec. I use the function RTC_DRV_SetAlarm to set the alarm and i reset the RTC timer to 0, so i have this condition:

  • Actual Time 00.00.00 01/01/1970, Allarm Time 0.4.30 01/01/1970

i read then some sensor and put the micro in VLLS1 with this function:

Peripheral_Disable();

  POWER_SYS_SetWakeupModule(kPowerManagerWakeupModule5, TRUE);

  error = CLOCK_SYS_UpdateConfiguration(2, kClockManagerPolicyAgreement);

  i = CLOCK_SYS_GetCoreClockFreq();

  POWER_SYS_SetMode(2, kPowerManagerPolicyAgreement);

the system wake up and in the llwu interrupt i have this:

PMC_REGSC = PMC_REGSC_ACKISO(1);

  PORT_HAL_ClearPortIntFlag(PORTD_BASE_PTR);

  if(POWER_SYS_GetWakeupModuleFlag(kLlwuWakeupModule5)){

  SIM_SCGC6 |= SIM_SCGC6_RTC_MASK;

  RTC_DRV_AlarmIntAction(RTCTimer_IDX);

  impulsi_pioggia=0;

  }

then the micro reinit doing this command:

/* Write your local variable definition here */
byte error = 0;

/*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/
PE_low_level_init();
/*** End of Processor Expert internal initialization.                    ***/

LPTMR_DRV_Start(Timer_1ms_IDX);
Init_UART0(48000, 115200);

#ifdef DEBUG

  debug_printf("////////////////////////////////////////////\r\n");

  debug_printf("////////////////////////////////////////////\r\n");

  RTC_DRV_GetDatetime(RTCTimer_IDX, &DataTime);

  debug_printf("Actual Time %02d.%02d.%02d %02d/%02d/%02d\r\n",

    DataTime.hour, DataTime.minute, DataTime.second, DataTime.day, DataTime.month, DataTime.year);

#endif

i read :  Actual Time 00.04.55 01/01/1970 so there are 25 sec of delay ... why this? they are so many...

In clock configuration 2 used in the VLLS1 i have set this clock

pastedImage_5.png

Thanks

0 Kudos
9 Replies

1,406 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

KL46 MCU wake up from VLLS1 to normal Run mode will go through wake-up reset (Follows the reset flow with the LLWU interrupt flag set for the NVIC).

For the RTC module doesn't affected with VLLS1 low power mode and  wake-up reset procedure, the timer will continue counting at VLLS1 low power mode.

That's why customer will find the RTC timer pass 25 seconds after VLLS1 low power mode wake up.


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,406 Views
danielecortella
Contributor V

Hello,

yes, but my question is why the cpu take 25 seconds to wakeup? It's a long time. Before the printf the only code executed is the peripherals init.

Thanks

0 Kudos

1,406 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

Could you provide the whole project source code?

I want to make sure the RTC counter value just before core enter into VLLS1 low power mode.

Customer doesn't need to update the core/system clock configuration before enter into VLLS1 mode.


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,406 Views
danielecortella
Contributor V

Hello,

here is the firmware. The system wake up at 5:23 instead the 5:00.

You can use the frdm kl46 to test this. I use themcuoneclipse library for the WAIT function.

Thanks

0 Kudos

1,406 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

There with a similar demo at <FRDM-KL46Z and TWR-KL46Z48M Sample Code Package> ​named [lcd_rtc_lowpower_tower] demo. The default project path is ..\kinetis_kl46_sc\kinetis_kl46_sc_rev2\klxx-sc-baremetal\build\iar\lcd_rtc_lowpower

The demo using RTC as wake up source and will wake up the KL46 from VLLS1 low power mode every 5 seconds.

I checked the KL46 reference manual, below picture shows the MCG module is OFF during VLLSx clock mode.

pastedImage_0.png

Customer could not using MCG IRC 32KHz clock as RTC module clock, the RTC module clock source with below option:

pastedImage_1.png

Customer need to use TWR-KL46Z48M to do the RTC wake up KL46 MCU from VLLS1 low power mode test, for the TWR-KL46Z48M board provides 32KHz oscillator connects with RTC_CLKIN pin.

pastedImage_2.png


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,406 Views
danielecortella
Contributor V

Hello,

yes in fact i use the LPO 1khz like clock source for the RTC. You can see this in the fsl_clock_manager, clock configuration 2.

Thanks

0 Kudos

1,406 Views
colin
Contributor III

Daniele Cortellazzi wrote:

yes in fact i use the LPO 1khz like clock source for the RTC.

If you are measuring the extra 23 seconds from real time (instead of from the RTC time on the MCU), it may be that the LPO 1 kHz clock's poor accuracy is to blame.  It is specified as 1 kHz +/- 10%, and 23 seconds in 5 minutes is about 8% error, so it's possible that is part of it.

1,406 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

I checked your project, In <Wakeup.h> with below definition:

#define MIN_WAKEUP 5

#define SEC_WAKEUP 00

pastedImage_0.png

If that code be updated before you sent the code?


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

1,406 Views
danielecortella
Contributor V

The firmware wake-up, reset the rtc in set_wakeup_timer and set the alarm after the MIN_WAKEUP (minutes) : SEC_WAKEUP (seconds). In the firmware sended the wakeup alarm is set after 5 minutes.

pastedImage_0.png

Thanks

AlarmDataTime = DataTime; AlarmDataTime.minute = MIN_WAKEUP; AlarmDataTime.second = SEC_WAKEUP;

0 Kudos