Trouble in waking up from VLLS1

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

Trouble in waking up from VLLS1

Jump to solution
942 Views
varunrajarangan
Contributor II

Hi,

I am trying to put KL05 to VLLS1 mode. I have configured LLW_P6 /PTB4 to wake up in falling edge.

My problem is, the microcontroller is going to VLLS1 mode. But It is not waking up when I change the state of LLW_P6/PTB4 to low.

/************************************************************ This is my code *************************************************************************/

#include "derivative.h" /* include peripheral declarations */

#include "SpiComm.h"

#include "dma.h"

#include "timer.h"

#include "globals.h"

#define    SET_NMI_INTERRUPT() SCB_ICSR |= SCB_ICSR_NMIPENDSET_MASK 

#define    PORTB_TOGGLE(n)            GPIOB_PTOR = 0x0001 << (n)

#define    PORTB_SET(n)            GPIOB_PSOR = 0x0001 << (n)

#define    PORTB_CLR(n)            GPIOB_PCOR = 0x0001 << (n)

#define    PORTB(n)                GPIOB_PDIR & (0x01 << (n))

void InitPortB(){

    SIM_BASE_PTR->SCGC5    |= 0x01 << 10;                    // Enable clock

    PTB_BASE_PTR ->PDDR    |= 0x01 << 8;                    // Direction : Output

    PTB_BASE_PTR->PDOR      = 0x01;                            // Initial value = 0

    PORTB_BASE_PTR->PCR[8]  = 0x01 << 8;                    // Enable MUX

   

    PTB_BASE_PTR->PDDR     &= ~(0x01 << 4);                    // PTB4 as input

    PORTB_BASE_PTR->PCR[4] |= 0x01 << 8;                    // Enable MUX for PTB4

    PORTB_BASE_PTR->PCR[4] |= 0x01 << 1;                    // Enable Pull-up/Pull-down

    PORTB_BASE_PTR->PCR[4] |= 0x01 << 0;                    // Enable Pull-up resistor

   

//    PORTB_BASE_PTR->PCR[4] |= 0x08 << 16;                   // Interrupt when logic '1'

//    NVIC_BASE_PTR->ISER    |= (uint32_t)(0x01 << 31);

    }

void InitPortA(){

    GPIOA_PDDR &= ~(0x1000);

    PORTA_PCR12 &= ~(0x01 << 8);

    PORTA_PCR12 |= 0x01 << 8;

    PORTA_PCR12 |= 0xB0000;

    ((NVIC_MemMapPtr)0xE000E100)->ISER |=0x01<<30;

    }

void Set_VLLS1(){

    uint8_t temp1 = 0;

// Configure VLLS Mode   

    SMC_PMPROT = 0x02;                 // Allow Low Leakage Power Modes (VLPR,VLPW,VLPS,LLS)

    temp1 = SMC_PMPROT;               // Dummy read

    SMC_PMCTRL = 0x04;                  // Run and Stop Mode Control (RUN,VLPR,VLPS,LLS,VLLSx) 

    temp1 = SMC_PMCTRL;                // Dummy read

    SMC_STOPCTRL = 0x01;              // Select VLLS1

// Configure Wakeup source

    LLWU_PE2  =  0x20;                // Enable LLW_P6/PTB4 as wakeup source (Falling edge)

    LLWU_ME   =  0x40;                // Enable LLWU Module 6

    LLWU_F1  |=  0x01 << 6;

    LLWU_F3  |=  0x01 << 6;

    }

int main(void)

{

    unsigned int count1 = 0x00;

   

    InitPortB();

    TimerInit();

    SPI_Init();                                            //

    Set_VLLS1();                                        // Configure sleep mode

   

    PORTB_SET(8);

   

    for(count1=0; count1<128; count1++){

        SpiBuff[count1] = 0x0A + count1;

        }

   

    while(1){

        if(TimeCount == 500){                                                      // If count reached

            TimeCount = 0;                                                          // Clear count               

            SCB_SCR|=SCB_SCR_SLEEPDEEP_MASK;             // Enable ARM deep sleep modes

             __asm("WFI");                                                         // Go to sleep

            }

       

        if(PORTB(4)){

            asm("nop");

            }

        }

    return 0;

}

Did I miss something or did I do something wrong??

Please help me guys..

Thanks and regards

Varun Rajarangan

Labels (1)
Tags (1)
1 Solution
763 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Varun Rajarangan,

    Yes, you are right, NVIC won't run in VLLS1, so actually the LLWU interrupt is executed after wakeup reset.

Wish it helps you!


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

3 Replies
763 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Varun Rajarangan,

      Please add this code in the beginning area of your main:

  if (PMC_REGSC & PMC_REGSC_ACKISO_MASK)

    PMC_REGSC |= PMC_REGSC_ACKISO_MASK;

  If it is still not OK, please refer to my code, find it from the attachment, I already set PTB4 rising as the VLLS1 wakeup source.

Wish it helps you!


Have a great day,

Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

763 Views
varunrajarangan
Contributor II

Hey Jingjing Zhou,

Thank you for your reply. I made it work by enabling the LLWU interrupt in NVIC-ISER.

I am a bit confused about what the datasheet says. It says that the NVIC is disabled in VLLS1 mode. Then what is the point in enabling the interrupt. Because if the NVIC is disabled, it should not serve any interrupts. Am I correct???

Regards

Varun Rajarangan

0 Kudos
764 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Varun Rajarangan,

    Yes, you are right, NVIC won't run in VLLS1, so actually the LLWU interrupt is executed after wakeup reset.

Wish it helps you!


Have a great day,
Jingjing

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------