MKL16 how to run in VLPRCO(Very low power run mode current in compute operation)

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

MKL16 how to run in VLPRCO(Very low power run mode current in compute operation)

1,307 Views
jiannianli
Contributor II

Hi , I need to let MKL16 work in low power ,  and now the current is very low in LLS mode . but when it work in VLPR and  do some data calculation ,the current is up to 1.4ma  . I had read the document and find VLPRCO mode ,  so how the mkl16 run to VLPRCO from VLPR ? 

thank you.

pastedImage_1.png

7 Replies

1,122 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Li ADai

  About the VLPR computer mode detail operation, I suggest you refer to the KL25 bare-metal code, which can be downloaded from this link:

https://www.nxp.com/downloads/en/lab-test-software/KL25_SC.exe 

KL25 Sample Code\kl25_sc_rev10\klxx-sc-baremetal\build\keil\low_power_demo

              case 0xf://Coremark in VLPR
                /*Maximum clock frequency for this mode is core 4MHz and Flash 1Mhz*/
                if ((SMC_PMSTAT & SMC_PMSTAT_PMSTAT_MASK)== 1){
                 printf("  in RUN Mode moving to VLPR\n\r ");
                    printf("Press any key to enter VLPR\n\r ");
                    uart0_getchar(UART0_BASE_PTR);
                    printf("Configure clock frequency to 4MHz core clock and 1MHz flash clock\n\r ");
                    vlp_clock_config(BLPE);
                    /*Go to VLPR*/
                    clockMonitor(OFF);
                    enter_vlpr();   // get out of VLPR back to RUN
                } 
                if ((SMC_PMSTAT & SMC_PMSTAT_PMSTAT_MASK)== 4){
                 printf("  in VLPR Mode !\n\r ");
                } else if ((SMC_PMSTAT & SMC_PMSTAT_PMSTAT_MASK)== 1){
                 printf("  in Run Mode  !\n\r ");
                    clockMonitor(ON);
                }
                op_mode = what_mcg_mode();
                if (op_mode ==1) 
                    printf("in BLPI mode now at %d Hz\r\n\r",mcg_clk_hz );
                if (op_mode ==2) 
                    printf(" in FBI mode now at %d Hz\r\n",mcg_clk_hz );
                if (op_mode ==3) 
                    printf(" in FEI mode now at %d Hz\r\n",mcg_clk_hz );
                if (op_mode ==4) 
                    printf(" in FEE mode now at %d Hz\r\n",mcg_clk_hz );
                if (op_mode ==5) 
                    printf(" in FBE mode now at %d Hz\r\n",mcg_clk_hz );
                if (op_mode ==6) 
                    printf(" in BLPE mode now at %d Hz\r\n",mcg_clk_hz );
                if (op_mode ==7) 
                    printf(" in PBE mode now at %d Hz\r\n",mcg_clk_hz );
                if (op_mode ==8) 
                    printf(" in PEE mode now at %d Hz\r\n",mcg_clk_hz );
                printf("\n\rTransitioning from VLPR mode \n\r"); 
                for (i=0;i<2;i++)
                  {
                     printf("Starting running Coremark in VLPR with--- CPO mode enabled. \n\r   ");
                     //enable_systick(0x00002000);
           enable_systick();
                     /* In compute mode */  
                     MCM_CPO |= MCM_CPO_CPOREQ_MASK;
                     while(!(MCM_CPO & MCM_CPO_CPOACK_MASK));
                     
                     wait();
                     /*****/
                     main_app(); //CoreMarks
                     /* Get Out of compute mode */
                     if(MCM_CPO & MCM_CPO_CPOACK_MASK){
                          MCM_CPO &= ~MCM_CPO_CPOREQ_MASK;
                          while (MCM_CPO & MCM_CPO_CPOACK_MASK);    
                     } else{
                       printf("Exiting test early - Did you disable LPTRM interrupt? \n\r");
                       break;
                     }
                     /****/
                     printf("  Back in VLPR mode \r\n"); 
                     printf("Starting running Coremark in VLPR without CPO mode enabled. \n\r"); 
                     main_app(); //CoreMarks
                     printf("Coremark iterations = 0x%02X of 2 \n\r",i) ;
                  }
   
                  break;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


            case 0x14: // enter compute mode
              if ((SMC_PMSTAT & SMC_PMSTAT_PMSTAT_MASK)== 4){
                 printf("  in VLPR Mode !  ");
                    wait_count = 20000000;
                } else if ((SMC_PMSTAT & SMC_PMSTAT_PMSTAT_MASK)== 1){
                 printf("  in Run Mode  !  ");
                    wait_count = 200000000;
                    // The next line is to resolve an errata where the LOCK bit is cleared in CPO
                    MCG_C5 |= MCG_C5_PLLSTEN0_MASK; // set PLLSTEN to keep PLL LOCK bit from clearing
                }
                op_mode = what_mcg_mode();
                if (op_mode ==1) 
                    printf("in BLPI mode now at %d Hz\r\n",mcg_clk_hz );
                if (op_mode ==2) 
                    printf(" in FBI mode now at %d Hz\r\n",mcg_clk_hz );
                if (op_mode ==3) 
                    printf(" in FEI mode now at %d Hz\r\n",mcg_clk_hz );
                if (op_mode ==4) 
                    printf(" in FEE mode now at %d Hz\r\n",mcg_clk_hz );
                if (op_mode ==5) 
                    printf(" in FBE mode now at %d Hz\r\n",mcg_clk_hz );
                if (op_mode ==6) 
                    printf(" in BLPE mode now at %d Hz\r\n",mcg_clk_hz );
                if (op_mode ==7) 
                    printf(" in PBE mode now at %d Hz\r\n",mcg_clk_hz );
                if (op_mode ==8) 
                    printf(" in PEE mode now at %d Hz\r\n",mcg_clk_hz );
                printf("Start Compute Mode --> waiting for %d counts   ", wait_count);
                enable_systick();
                /* In compute mode */  
                MCM_CPO |= MCM_CPO_CPOREQ_MASK;
                while(!(MCM_CPO & MCM_CPO_CPOACK_MASK));
                     
                wait();
                for (i=0;i<wait_count;i++){
                     if(!(MCM_CPO & MCM_CPO_CPOACK_MASK))
                           break;               
                }      
                if(MCM_CPO & MCM_CPO_CPOACK_MASK){
                  MCM_CPO &= ~MCM_CPO_CPOREQ_MASK;
                  while (MCM_CPO & MCM_CPO_CPOACK_MASK);    
                }           
                printf("         \n\rWaiting is Over - Now OUT of Compute Mode\n\r ");
                break;   

Wish it helps you!

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

1,122 Views
jiannianli
Contributor II

I had try and it work ok ,  thank you very much

0 Kudos

1,122 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Li ADai,

   You are welcome.

   That low power code is the complete code, and can be used in the KL16 series.

   Wish it helps you!

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,122 Views
jiannianli
Contributor II

Hi ,Kerry

thank you very much.

now I still have some questions .  there are 2 code test under ,why the current so high when do some compute ? I need calculate some float data .   

Current difference is:   1.26ma-348ua=912ua   

//************code test 1:do_Some_compute****************************************
// takes 1.26ma in compute mode ,and 1.414ma will take if not enter compute mode ,
//******************************************************************************
enter_vlpr();
//enter In compute mode
MCM_CPO |= MCM_CPO_CPOREQ_MASK;
while(!(MCM_CPO & MCM_CPO_CPOACK_MASK)){};
while(1)//
{
do_Some_compute();
};
//ouot compute mode
MCM_CPO &= ~MCM_CPO_CPOREQ_MASK;
while (MCM_CPO & MCM_CPO_CPOACK_MASK);


//************code test 2: do nothing *****************************************
// takes 348ua in compute mode, and 556ua will take if not enter compute mode ,
//*****************************************************************************
enter_vlpr();
//enter In compute mode
MCM_CPO |= MCM_CPO_CPOREQ_MASK;
while(!(MCM_CPO & MCM_CPO_CPOACK_MASK)){};

while(1)//
{
// do_Some_compute();
};

//ouot compute mode
MCM_CPO &= ~MCM_CPO_CPOREQ_MASK;
while (MCM_CPO & MCM_CPO_CPOACK_MASK);

0 Kudos

1,122 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Li ADai,

   My understanding is the compute operation code execution also consumes the power. That's why the datasheet test the power consumption with while(1) loop executing.

   Wish it helps you!

If you still have questions about it, please kindly let me know.

Best Regards,

Kerry

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

1,122 Views
jiannianli
Contributor II

Hi ,Kerry:

 thank you very much .  

I will try other way to reduce the power .

0 Kudos

1,122 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Li ADai,

  You are welcome!

  If you have any other question, welcome to create the new case about it.

Best Regards,

Kerry

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos