KL26 VLPS mode (very low power stop mode)

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

KL26 VLPS mode (very low power stop mode)

Jump to solution
2,669 Views
joaquimmartinez
Contributor II

Hi all,

I'm using a FRDM-KL26Z demo board, REV E and code mark MKL26Z128VLH4 / 1N15J / CTCTAB1340L.

I'm trying to configure the MCU into VLPS mode to achieve 2.8-7.8uA (as specified in the datasheet).

I'm using the example in the AN4503 - 8.1.9. Entering VLPS mode (page 24). I'm using the functions "enter_vlps()" and "deepsleep()". In my code, the CME0 bit is 0, the ALVP bit is 1 and the STOPM bits are b10. With this code the MCU current is 150uA, too far from the 2.8-7.8uA specified..

In the page 5 of the AN4503 (point 2.1.8. Very Low Power Stop mode) there is a sentence that says: "Expect IDD from 0.2 to 1 mA. Use of BLPE mode is recommended for VLPR and VLPS operation. See errata for more information.".

I've read the "Mask Set Errata for Mask 1N97F" the errata ID 5666 and says:

e5666: PMC: Maximum current consumption in VLPR, VLPW, VLPS, LLS and VLLS modes may be higher than data sheet specification.

Errata type: Errata

Description: Maximum current consumption in Very Low Power Run (VLPR), Very Low Power Wait (VLPW), Very Low Power Stop (VLPS), Low Leakage Stop (LLS) ,Very Low Leakage Stop3 (VLLS3) ,Very Low Leakage Stop2 (VLLS2) ,Very Low Leakage Stop1 (VLLS1) , and Very Low Leakage Stop0 (VLLS0) modes within an operating range of -40°C to 25°C may exceed data sheet specification.

Note: Some devices do not feature all of the power modes listed above. Refer to the

Reference Manual to determine if a particular low power mode is available on your device.

Workaround: If maximum current consumption in these low power modes exceed system requirements, a higher power mode should be used.

So I have a few questions:

1. Can this explain my consumption of 150uA in this mode??

2. What means exactly "Use of BLPE mode is recommended for VLPR and VLPS operation" in the page 5 of the AN4503? I'm using a BLPI, The internal reference 32.768KHz clock.

3. If I use an external 32KHz clock, the consumption will be the specified?

4. The code mark of the chip has this problem described in the errata?

Thanks for your help.

Joaquim.

Tags (1)
1 Solution
1,366 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Joaquim,

Thanks for your reply at first.

Yes, there's no option provided in PEx low power demo, however you can add these code as below to enter VLPS mode.

After tested, the result turn out be good.

So please refer to these code as below and test it by yourself.

     /* SCB_SCR: SLEEPDEEP=1 */
      SCB_SCR |= SCB_SCR_SLEEPDEEP_MASK; 
      SMC_PMPROT = SMC_PMPROT_AVLP_MASK;                              
      /* SMC_PMCTRL: STOPM=0 */
      SMC_PMCTRL &= (uint8_t)~(uint8_t)(SMC_PMCTRL_STOPM(0x07)); 
      SMC_PMCTRL |=  SMC_PMCTRL_STOPM(0x2);
      (void)(SMC_PMCTRL == 0U);    /* Dummy read of SMC_PMCTRL to ensure the register is written before enterring low power mode */
      /* SCB_SCR: SLEEPONEXIT=0 */
      SCB_SCR &= (uint32_t)~(uint32_t)(SCB_SCR_SLEEPONEXIT_MASK);                             
      PE_WFI();
    
      if (TmrWkupFlg)
      {
      printf("\nWoke-up via Timer!\n\n");
          TmrWkupFlg = FALSE;
      }
      // Disable Timer
      Wkup_Tmr_Disable();
    
      // Wait for clocks to stabilize
      for (i=0; i<20000; i++)
      {}
    
      printf("Woke up from VLPS!! \n\n");
       }


Have a great day,
Ping

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

View solution in original post

0 Kudos
15 Replies
1,366 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Joaquim,

I'm confused with the consuption of current is 150uA in VLPS mode and I think it's unnomal even the MCU has the bug like the errata states.

So I'd like to suggest that you'd better use the low power demo code which from FRDMKL26M sample code package to test again and please update me ASAP if you have the result.

About the sentence "Use of BLPE mode is recommended for VLPR and VLPS operation. See errata for more information", to be honest, I've had no idea with that now and I'll update you later if I work it out.

Of courese, the consumption is specific if you use an exteral 32 Khz clock.

Hope this reply help.
Have a great day,

Ping

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

0 Kudos
1,366 Views
joaquimmartinez
Contributor II

Hi Ping,

Thank you very much for youer help.

I have measured the current for all low power modes of the example (PEx low power demo). Here the values:

MODE NORMAL WAITMODE (OPTION 2 OF THE MENU):

Measured: 4.5mA.

MODE NORMAL STOP MODE (OPTION 3 OF THE MENU):

Measured: 240uA.

MODE NORMAL VLLSx MODE (OPTION 4 OF THE MENU):

Measured: 67uA.

MODE NORMAL VLPR MODE (OPTION 5 OF THE MENU):

Measured: 160uA.

Considerations:

1. I'm using a FRDM-KL26Z demo board, REV E and chip code mark MKL26Z128VLH4 / 1N15J / CTCTAB1340L.

2. I have tested in two identical boards and the results are the same.

3. In the example I think that the 32KHz is internal.

4. If a use an external 32KHz, Do the current will decrease?

My specifications:

1. I need to work in the VLPS mode (2.8-7.8uA) because is the low power mode that will allow to wakeup the MCU when it's sleeping, if an UART or LPTMR interruption occurs.

2. I just need a function to Sleep and Wakeup the micro when I need it.

3. In the PEx low power demo, the VLPS mode doesn't appears, so I have write the code in the example AN4503 - 8.1.9. Entering VLPS mode (page 24), but the current is too high (around 150uA).

3. In addition, I need that the LPTMR have a time base of ms or sec. I need a configuration/function that allows pass a param to set the timer with a timeout in ms or seconds.

4. I'm using the Processor Expert and it's difficult to configure it...

My questions:

1. Please, have you a concrete example with the correct configuration for using the VLPS mode?

2. Have you a concrete example with the correct configuration for using the LPTMR with base time in ms and seconds?

Please, I need a quick help beacuse, due to the timing in my project, I have to buy 1000 units of the KL26 and I need to be sure that the current consumption is according to the datasheet.

Thank you very much.

Joaquim.

0 Kudos
1,366 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Joaquim,

Sorry for delay reply since I had been on business recently.

I'll try run the low power demo code with FRDMKL26M board by myself and update you if I get result.

I apologize for bringing any inconvenience to you.
Have a great day,
Ping

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

0 Kudos
1,366 Views
joaquimmartinez
Contributor II

Hi Ping,

Thank you very much for your help.

BR,

Joaquim.

0 Kudos
1,366 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Joaquim,

I've tested the low power demo which doesn't integrate the PE and you also can find this demo throught this path <dir_stall>\FRDM-KL26Z_SC_Rev_1.0\klxx-sc-baremetal\build\iar\low_power_demo.

These figures below show the test resut. and the current consumption conforms to the data sheet specification.

So I'd like to suggest that you can test this demo by yourself.

Hope this reply hope.

Have a great day,

Ping

1. In RUN mode

IMG_20140902_171355.jpg

2. In VLPS mode

IMG_20140902_163831.jpg

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

1,366 Views
joaquimmartinez
Contributor II

Hi Ping,

Thanks for the answer.

Unfortunately I don't have the IAR compiler... I'm using CodeWarrior and the PE.

Wha'ts the different between projects?

Have you tested the current consumption for the PE_low_power example? If not, can you test it please?

Thanks.

0 Kudos
1,367 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Joaquim,

Thanks for your reply at first.

Yes, there's no option provided in PEx low power demo, however you can add these code as below to enter VLPS mode.

After tested, the result turn out be good.

So please refer to these code as below and test it by yourself.

     /* SCB_SCR: SLEEPDEEP=1 */
      SCB_SCR |= SCB_SCR_SLEEPDEEP_MASK; 
      SMC_PMPROT = SMC_PMPROT_AVLP_MASK;                              
      /* SMC_PMCTRL: STOPM=0 */
      SMC_PMCTRL &= (uint8_t)~(uint8_t)(SMC_PMCTRL_STOPM(0x07)); 
      SMC_PMCTRL |=  SMC_PMCTRL_STOPM(0x2);
      (void)(SMC_PMCTRL == 0U);    /* Dummy read of SMC_PMCTRL to ensure the register is written before enterring low power mode */
      /* SCB_SCR: SLEEPONEXIT=0 */
      SCB_SCR &= (uint32_t)~(uint32_t)(SCB_SCR_SLEEPONEXIT_MASK);                             
      PE_WFI();
    
      if (TmrWkupFlg)
      {
      printf("\nWoke-up via Timer!\n\n");
          TmrWkupFlg = FALSE;
      }
      // Disable Timer
      Wkup_Tmr_Disable();
    
      // Wait for clocks to stabilize
      for (i=0; i<20000; i++)
      {}
    
      printf("Woke up from VLPS!! \n\n");
       }


Have a great day,
Ping

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

0 Kudos
1,366 Views
joaquimmartinez
Contributor II

Hi Ping,

Finally I can to enter into VLPS mode and now my current consumption is 2.8uA!!! Thank you very much for your help in this issue.

Now I'm trying to use the UART0 in VLPS mode. Basically my app is sleeping and I when a RX frame from UART0, the KL26 wakeup. I'm trying to configure this, but the KL26 doesn't wakeup, even if in the RX pin is active (the slave sends frames to the KL26).

I've found a documentation "KLQRUG.pdf" with an example (example 2: functionality of UART0 in VLPS mode), and I've written the code in my app (with a little modifications to adapt it to my hard and config), but the KL26 is always sleeping.

Please, can you help me in this new issue?

I explain you my configuration:

1. I'm using the same clock configuration of the PEx_lowpower_example.

2. I'm using the PE for the UART0 (AS1). Is a CPU Internal Peripherals. Please, see the image below:

UART0_PE_config.jpg

2. After the function PE_low_level_init();, I've tried 3 different UART0 configurations to wakeup the KL26, but the results are the same, no wakeup:

2.1. Using only the PE with setting "Wakeup condition == Idle line wakeup"

2.2. Using only the PE with setting "Wakeup condition == Address mark wakeup"

2.3. Using only the PE with setting "Wakeup condition == Address mark wakeup" and reconfiguring the UART0 with the code:

NOTE: my freceived frame would be:

FF 02 0C 22 13 63 4B 30 52 39 01 21 93 4C 03

void HalUART0VLPS(void)

{

  //SIM_SOPT2 |= SIM_SOPT2_UART0SRC(1);

  //SIM_SOPT2 |= SIM_SOPT2_PLLFLLSEL_MASK;

  /*SIM_SOPT2 = SIM_SOPT2_UART0SRC(3);

  SIM_SCGC4 = SIM_SCGC4_UART0_MASK;

  SIM_SCGC5 = SIM_SCGC5_PORTA_MASK;

  */

  PORTA_PCR1 = PORT_PCR_ISF_MASK | PORT_PCR_MUX(0x2);

  PORTA_PCR2 = PORT_PCR_ISF_MASK | PORT_PCR_MUX(0x2);

  UART0_C2 &= ~ (UART0_C2_TE_MASK | UART0_C2_RE_MASK);

  UART0_BDH = 0x00;

  UART0_BDL = 0x34;

  UART0_C4 = 0x0F;

  //UART0_C1 = UART0_C1_WAKE_MASK;

  //UART0_C3 = 0x00;

  UART0_MA1 = 0xFF;

  UART0_MA2 = 0x02;

  UART0_C2 = UART0_C2_RWU_MASK | UART0_C2_RIE_MASK;

  UART0_S1 |= 0x1F;

  UART0_S2 |= 0xC0;

  UART0_C2 |= UART0_C2_TE_MASK | UART0_C2_RE_MASK;

  //UART0_C2 = UART0_C2_RWU_MASK | UART0_C2_RIE_MASK | UART0_C2_ILIE_MASK;

}

By default, the TX and RX line are "1" logical value, because my slave device doesn't support inverted mode.

Please, can you help me on this?

Thank very much in advance.

Joaqui.

0 Kudos
1,366 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Joaquim,

I'd like to suggest that you'd better use choose the component to implement in the project (Fig 1). Because this component support more paramenters to set, then it's easily for you to migrate the functionality of UART0 in VLPS mode in KLRUG.pdf to your project.

2.jpg

                                                      Fig 1
Have a great day,
Ping

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

0 Kudos
1,366 Views
joaquimmartinez
Contributor II

Hi Ping,

I used this new component and I used it. The problem is that the Init_UART doesn't have neither methods nor events to use (for example to send a block or receive blocks). This is because I'm using the AS1:AsynchroSerial component.

In addition, is not possible to share the UART0 with both components.

If I use the Init_UART component, what functions to send and receive must I to use?

Thanks.

0 Kudos
1,366 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Joaquim,

Thanks for your reply.

PE doesn't support two components to share one module simultaneously and I'd like to suggest that you should save Init_UART component.

About the send and receive function of UART, you could refer to the code from UART0 in VLPS mode in KLRUG.pdf and I've also included with this reply.

You can also upload your simple demo about UART0 in VLPS and I'll run it with FRDMKL26M board later.
Have a great day,
Ping

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

1,366 Views
joaquimmartinez
Contributor II

Hi Ping,

Finally I have solved the issue.

Basically before to entering tin VLPS mode, I have to chanege the clock to internal 4MHz, and associate the internal clock to UART.

Thank you very much for your help!

Joaquim.

0 Kudos
1,366 Views
joaquimmartinez
Contributor II

Hi Ping,

I've just configured the UART with Init_UART Component.

I've created a simple code to receive frames. It works fine in RUN mode, but in VLPS I have the same problem, the KL26 is always sleeping. I've used wakeup idle and mask.

I'm thinking that in VLPS is not possible to wakeup the KL26...

I sent you my code:

/*

* AS1_Received INT

*/

PE_ISR(UART0_ISR)

{

// NOTE: The routine should include actions to clear the appropriate

//       interrupt flags.

//

  if (UART0_S1 & UART_S1_RDRF_MASK)

  {

       HalRxWaveCard();

  }

}

uint8_t AS1_RecvChar(uint8_t *pByteReceived)

{

  *pByteReceived = UART0_D;

  return ERR_OK;

}

void HalRxWaveCard (void)

{

uint8_t ByteReceived;

  uint8_t err = AS1_RecvChar((byte *) &ByteReceived);

  if (err == ERR_OK)

  {

     // My app functions

  }

}


Please, can you help me? Is my component configuration ok?


Thanks





0 Kudos
1,366 Views
joaquimmartinez
Contributor II

Sorry, here the images.

Init_UART0_config_1_of_2.jpgInit_UART0_config_2_of_2.jpg

0 Kudos
1,366 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Joaquim,

I've not tested the code which use the UART to wake up the MCU from VLPS mode before.

So I think I need some time to make it and I'll update you later.

Please be patient and thanks for understanding.
Have a great day,
Ping

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

0 Kudos