K60 wake up from VLLS3 mode through RTC failed

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

K60 wake up from VLLS3 mode through RTC failed

928 Views
Karts
Contributor I
 

Hello there,

I configured RTC timer to generate interrupts every one second.Also.RTC is configured to use LLWU module to wake up K60 from sleep deep mode.I put the K60 module to VLLS3 deep sleep mode.I find that K60 does not wake up from VLLS3 mode.

 

Unable to attach the files:

 

Here is the code for RTC initialization:

 

void rsi_mcu_rtc_init(uint32 time_in_seconds)
{
    uint32 i;
    
    rsi_sleep_time_in_seconds = time_in_seconds;
    
    /* Enable clock to LLWU module */
    SIM_SCGC4 |= SIM_SCGC4_LLWU_MASK ;
    
    /* Enable the clock to SRTC module register space*/
    SIM_SCGC6 |= SIM_SCGC6_RTC_MASK;
    
    /* Configure RTC as a wake up source through LLWU module */
    LLWU_ME |= LLWU_ME_WUME5_MASK ;
    
    /*Only VBAT_POR has an effect on the SRTC, RESET to the part does not, so you must manually reset the SRTC to make sure everything is in a known state*/
    /*clear the software reset bit*/
    RTC_CR  = RTC_CR_SWR_MASK;
    RTC_CR  &= ~RTC_CR_SWR_MASK;
    
    /* Enable RTC interrupt in NVIC */
    enable_irq(66);
    
    /* Enable low leakage wake up interrupt */
    enable_irq(21);
    
        
    /*Enable the oscillator*/
    RTC_CR |= RTC_CR_OSCE_MASK;
      
    /*Wait to all the 32 kHz to stabilize, refer to the crystal startup time in the crystal datasheet*/
    for(i=0;i<0x1000000;i++);
    
        
    /* Set seconds register */
    RTC_TSR = (time_in_seconds);
    
    /* Set alarm register */
    RTC_TAR = RTC_TSR;
    

    /* Enable the counter */
    RTC_SR |= RTC_SR_TCE_MASK;
    
    
}


void rsi_rtctimer_ISR(void)
{
     if((RTC_SR & RTC_SR_TIF_MASK)== 0x01)
     {
//         printf("SRTC time invalid interrupt entered...\r\n");
         RTC_SR &= 0x07;  //clear TCE, or RTC_TSR can  not be written
         RTC_TSR = 0x00000000;  //clear TIF
     }
     else if((RTC_SR & RTC_SR_TOF_MASK) == 0x02)
     {
//         printf("SRTC time overflow interrupt entered...\r\n");
         RTC_SR &= 0x07;  //clear TCE, or RTC_TSR can  not be written
         RTC_TSR = 0x00000000;  //clear TOF
     }
     else if((RTC_SR & RTC_SR_TAF_MASK) == 0x04)
     {
//         printf("SRTC time alarm interrupt entered...\r\n");
         rsi_rtc_interrupt_flag++;
         RTC_TAR += 1;// Write new alarm value, to generate an alarm every second add 1
     }    
     else
     {
//         printf("No valid Flag was set!\n");
     }
    
     return;
}

 

Here is the code for VLLS3 configuration :

 

void enter_vlls3(void)
{

    /* Write to PMPROT to allow VLLS3 power modes */
    MC_PMPROT = MC_PMPROT_AVLLS3_MASK;
    
    /* Set the LPLLSM field to 0b101 for VLLS3 mode  */
    MC_PMCTRL = MC_PMCTRL_LPLLSM(5);           // set LPLLSM = 0b101
    
    /* Disable PORT modules */
    //disable_ports();    
    
   // printf("Entering VLLS3 power save mode\n");
    
    /* Now execute the stop instruction to go into VLLS3 */
    stop();

}

void stop(void)
{

    /* Set the SLEEPDEEP bit to enable deep sleep mode (STOP) */
    SCB_SCR |= SCB_SCR_SLEEPDEEP_MASK;    

    /* WFI instruction will start entry into STOP mode */
    asm("WFI");

}

 

 

The K60 module used is MK60DN512Z10 (Rev 1.4) with 4N30D - MASK


Appreciate any help to debug this issue.

Thanks.

0 Kudos
Reply
1 Reply

462 Views
egoodii
Senior Contributor III

Check a recent K60xxxRM document on RTC, and the new Interrupt Enable Register -- you may need to set this:

        if ((SIM_SDID & SIM_SDID_REVID_MASK) != 0)  // Only for Rev 1.1 and higher silicon
        {
            // Make sure RTC interrupts are enabled, since these may have been disabled at some
            // point, and the register is battery backed. No need for this on the 1.0 silicon,
            // since this register served a different purpose (flash swap) in that rev.
            rtc->IER = (RTC_IER_TIIE_MASK | RTC_IER_TOIE_MASK | RTC_IER_TAIE_MASK);

        }

 

Also, it seems to me you need to set TAR to at least 1 more than TSR to get that first interrupt.

0 Kudos
Reply