AnsweredAssumed Answered

KL05 exiting low power without input

Question asked by Bryan Olinger on Feb 17, 2015
Latest reply on Feb 17, 2015 by Mark Butcher

We needed to switch the gpio port that was being used to bring the KL05 out of VLLS1 mode.  We were using PTB0 (a supported LLWU pin) that was wired to an accelerometer interrupt line that generated a falling edge when a double tap is detected.  This would change the state and/or bring the system out of VLLS1 mode.  That worked perfectly.  Then we needed to switch the design to use a force sensing resistor with a pullup (instead of the accelerometer double tap detect) on PTB2.  The issue we are having is that the KL05 enters the VLLS1, but doesn't stay there.  It immediately comes out of VLLS1 without any input.  The system can literally sit there without being touched and will enter and then immediately exit VLLS1 mode.  I have a scope probe on the FSR line and the pin is not going low (trigger set all the way up to 2.5v).

 

Below is the gpio init code, interrupt handler, and code snippet showing system going into VLLS1 mode.  The code for PTB0 is commented out and the code for PTB2 is right above it.

 

void gpio_init(void)

  // FSR press detect

  PORTB_PCR2 = PORT_PCR_MUX(1)      // Alt1: GPIO

              | PORT_PCR_IRQC(0x0A); // Falling edge

 

  PORTB_PCR2 |= PORT_PCR_ISF_MASK; // clear flag

 

/* 

  // MMA845x INT2 - Double pulse detection    

  PORTB_PCR0 = PORT_PCR_MUX(1)      // Alt1: GPIO

              | PORT_PCR_IRQC(0x0A) // Falling edge

              | PORT_PCR_PE_MASK    // Pull enable

              | PORT_PCR_PS_MASK;   // Pull select - pullup

 

  PORTB_PCR0 |= PORT_PCR_ISF_MASK; // clear flag

*/

      

  enable_irq(INT_PORTB - 16);

}

 

void PORTB_IRQHandler(void)

{

  if(PORTB_PCR2 & PORT_PCR_ISF_MASK)

  {

    delay_ms(1000);

   

    if(GPIOB_PDIR | 1<<2)

    {

      state_change(0);         

      printf("\r\nFSR press\r\n");   

    }

     

    // Clear the interrupt flag

    PORTB_PCR2 |= PORT_PCR_ISF_MASK;

 

  }

 

/*   

  if(PORTB_PCR0 & PORT_PCR_ISF_MASK)

  {

    MMA845x_pulse_flag_set();

     

    // Read the INT_SOURCE register

    tmp = hal_dev_mma8451_read_reg(0x0C);

   

    if((tmp & 0x08) == 0x08)

    {

      // Yes.  Read the (PULSE_SRC) Pulse source register to clear the flag.

      tmp = hal_dev_mma8451_read_reg(0x22);

     

      // Double pulse has been detected - change state

      state_change(0);     

    }

   

    // Clear the interrupt flag

    PORTB_PCR0 |= PORT_PCR_ISF_MASK;

  }

*/ 

}

 

 

// Code to go into VLLS1

 

        case LOW_POWER_STATE:

        {

            // Turn off LEDs

            PORTB_PCR10 = PORT_PCR_MUX(1);

            GPIOB_PDDR |= 0x00000400;

            GPIOB_PSOR |= 0x00000400;   


            // Disable SWD pin

            PORTA_PCR0 = PORT_PCR_MUX(1);

            PORTA_PCR2 = PORT_PCR_MUX(1);       

           

            // Put KL05 in low power

            SMC_PMPROT = SMC_PMPROT_AVLLS_MASK;    // Allow device to go into low-leakage power mode

            SMC_PMCTRL = SMC_PMCTRL_STOPM(4);     

            SMC_STOPCTRL = SMC_PMCTRL_STOPM(1);    // VLLS1

 

            dummyread=SMC_PMCTRL;                  // Give time for PMCTRL register to write

            MCG_C6&=~MCG_C6_CME0_MASK;             // Turn off Clock Monitor

 

            // LLWU config

            LLWU_F1  |= LLWU_F1_WUF5_MASK;         // Clear wakeup flag for PTB2/LLWU_P5

            LLWU_PE2 = LLWU_PE2_WUPE5(2);          // Configure wakeup on PTB2/LLWU_P5 (falling edge)

            LLWU_ME  = LLWU_ME_WUME5_MASK;

/*           

            LLWU_F1  |= LLWU_F1_WUF4_MASK;       // Clear wakeup flag for PTB0/LLWU_P4 (Accelerometer INT2 line to PTB0)

            LLWU_PE2 = LLWU_PE2_WUPE4(2);       // Configure wakeup on PTB0/LLWU_P4 (falling edge)

            LLWU_ME  = LLWU_ME_WUME4_MASK;

*/

            while(1)

            {

              stop();

            }           

        }       

Outcomes