AnsweredAssumed Answered

Use RTC Alarm to wakeup K64 from VLLSx

Question asked by Will X on Oct 21, 2015
Latest reply on Dec 8, 2015 by Will X

Hello,

 

I'm having a hard time using the RTC Alarm as a wakeup source from VLLS0/1/2/3 on the K64 and  wondering if anyone here can be of help.

 

I'm setting bit 5 of the LLWU_ME to enable the RTC Alarm as a wakeup module. I can go into VLLS successfully but never leave and reset using RTC Alarm. The alarm I’m setting is just 30 seconds in the future. So I read the current time from RTC_TSR and increment it by 30. I'm able to use the LPTMR to wake up from VLLS1 but RTC Alarm never works from any of the VLLS levels. So the VLLS part is fine but having the RTC Alarm trigger a LLWU is not.

 

Here's some snippets of the relevant parts of the code. Any help would be greatly appreciated!

 

The RTC is initialized in the following way:

 

void rtc_init(void)

{
   SIM_SCGC6 |= SIM_SCGC6_RTC_MASK;

 

   // Check Oscillator Enable

   if((RTC_CR & RTC_CR_OSCE_MASK) == 0)

   {

      RTC_CR |= RTC_CR_OSCE_MASK; // Enable Oscillator

      delay_us(RTC_OSC_STARTUP_DELAY_US); // Wait for oscillator to startup

   }

 

   SIM_SOPT1 |= SIM_SOPT1_OSC32KSEL(3);

   RTC_CR &= ~RTC_CR_CLKO_MASK; // The 32kHz clock is output to other peripherals

   SIM_SOPT2 |= SIM_SOPT2_RTCCLKOUTSEL_MASK; // Output the 32kHz RTC to RTC_CLKOUT

 

   RTC_IER |= RTC_IER_TAIE_MASK; // Enable Alarm Interrupt

   RTC_IER |= RTC_IER_TOIE_MASK; // Enable overflow interrupt

   RTC_IER |= RTC_IER_TIIE_MASK; // Enable time invalid interrupt

 

   enable_int_vector(INT_RTC, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);

}

 

Before going to VLLS we do the following:

 

       LLWU_ME |= LLWU_ME_WUME5_MASK

 

       // Clear external pin LLWU flags

       LLWU_F1 = 0xFF;

       LLWU_F2 = 0xFF;

 

The LLWU IRQ handler is:

 

 

__sysfunc void LLWU_IRQHandler(void)

{

   // Clear external pin LLWU flags

   LLWU_F1 = 0xFF;

#ifdef LLWU_F2

   LLWU_F2 = 0xFF;

#endif

 

   // Clear any filters
   if(LLWU_FILT1 & LLWU_FILT1_FILTF_MASK) {

     LLWU_FILT1 |= LLWU_FILT1_FILTF_MASK;

   }

 

   if(LLWU_FILT2 & LLWU_FILT2_FILTF_MASK) {

     LLWU_FILT2 |= LLWU_FILT2_FILTF_MASK;

   }

}

Outcomes