AnsweredAssumed Answered

how to put MKL04 to deep sleep.

Question asked by davidsun on Jun 8, 2014
Latest reply on Sep 27, 2015 by James Millard

I am trying to use the following code to put the chip in deep sleep mode to save current.

 

these few lines is copied from low power demo

 

     PORTA_PCR7 = PORT_PCR_MUX(1);      //p3

//     llwu_configure(1<<3, LLWU_PIN_RISING, 0);

       SMC_PMPROT = SMC_PMPROT_AVLLS_MASK;   

      SMC_PMCTRL = SMC_PMCTRL_STOPM(4);     

      SMC_STOPCTRL = SMC_PMCTRL_STOPM(0) | SMC_STOPCTRL_PORPO_MASK;  // disable POR circuit 

     

the PTB3 toggle before this code, I expected the PTB3 will not toggle after above code, but seems to me the above code won't set the chip in low power mode.

 

I am a hw engineer. with limited program knowledge. could any one give me some detail instruction to set this chip in deep sleep mode, I don't need to wake it up. this is just a back up chip. when I need it, I will reload the flash.

 

sincerely.

 

David

 

 

/* ###################################################################

**     Filename    : ProcessorExpert.c

**     Project     : ProcessorExpert

**     Processor   : MKL04Z8VFK4

**     Version     : Driver 01.01

**     Compiler    : IAR ARM C Compiler

**     Date/Time   : 2014-05-27, 10:23, # CodeGen: 0

**     Abstract    :

**         Main module.

**         This module contains user's application code.

**     Settings    :

**     Contents    :

**         No public methods

**

** ###################################################################*/

/*!

** @file ProcessorExpert.c

** @version 01.01

** @brief

**         Main module.

**         This module contains user's application code.

*/       

/*!

**  @addtogroup ProcessorExpert_module ProcessorExpert module documentation

**  @{

*/       

/* MODULE ProcessorExpert */

 

 

/* Including needed modules to compile this module/procedure */

#include "Cpu.h"

#include "Events.h"

#include "GPIO1.h"

/* Including shared modules, which are used for whole project */

#include "PE_Types.h"

#include "PE_Error.h"

#include "PE_Const.h"

#include "IO_Map.h"

//#include "llwu.h"

 

 

/* User includes (#include below this line is not maintained by Processor Expert) */

LDD_TDeviceData *MyGPIO1Ptr;

/*lint -save  -e970 Disable MISRA rule (6.3) checking. */

int main(void)

/*lint -restore Enable MISRA rule (6.3) checking. */

{

  /* Write your local variable definition here */

    unsigned int i,j, k;

  /*** Processor Expert internal initialization. DON'T REMOVE THIS CODE!!! ***/

  PE_low_level_init();

  /*** End of Processor Expert internal initialization.                    ***/

  MyGPIO1Ptr = GPIO1_Init((LDD_TUserData *)NULL);

  /* Write your code here */

  /* For example: for(;;) { } */

  PORTB_PCR6 |= PORT_PCR_MUX(0x01);

  PORTB_PCR6 |= 0x03;

  GPIOB_PDDR |= 0X40;

 

  for(k=0;k<10;k++)

  {

    for(j=0;j<2;j++)for(i=0;i<6553;i++);

   GPIO1_ToggleFieldBits(MyGPIO1Ptr, PTB3, 0x1U);                            // this code works

   GPIOB_PTOR |= 0x40;

      //GPIOB_PTOR |= 0x40;

 

  }

  // the following 4 lines is I copied from low power demo program provide by Freescale. I don't know what this means, all I need to do is put the chip in sleep mode and I may use them later.

     PORTA_PCR7 = PORT_PCR_MUX(1);      //p3

//     llwu_configure(1<<3, LLWU_PIN_RISING, 0);

       SMC_PMPROT = SMC_PMPROT_AVLLS_MASK;   

      SMC_PMCTRL = SMC_PMCTRL_STOPM(4);     

      SMC_STOPCTRL = SMC_PMCTRL_STOPM(0) | SMC_STOPCTRL_PORPO_MASK;  // disable POR circuit 

    

       for(k=0;k<10;k++)

  {

    for(j=0;j<2;j++)for(i=0;i<655;i++);

   GPIO1_ToggleFieldBits(MyGPIO1Ptr, PTB3, 0x1U);                     // I still can see the signal toggle, which is not expected. I hope the chip in sleep mode

   GPIOB_PTOR |= 0x40;

      //GPIOB_PTOR |= 0x40;

 

  }

 

 

//        printf("\n enter into VLLS0_2 mode--.\n");

//      SMC_PMPROT = SMC_PMPROT_AVLLS_MASK;  

//      SMC_PMCTRL = SMC_PMCTRL_STOPM(4);    

//      SMC_STOPCTRL = SMC_PMCTRL_STOPM(0) | SMC_STOPCTRL_PORPO_MASK;  // disable POR circuit

 

  /*** Don't write any code pass this line, or it will be deleted during code generation. ***/

  /*** RTOS startup code. Macro PEX_RTOS_START is defined by the RTOS component. DON'T MODIFY THIS CODE!!! ***/

  #ifdef PEX_RTOS_START

    PEX_RTOS_START();                  /* Startup of the selected RTOS. Macro is defined by the RTOS component. */

  #endif

  /*** End of RTOS startup code.  ***/

  /*** Processor Expert end of main routine. DON'T MODIFY THIS CODE!!! ***/

  for(;;){}

  /*** Processor Expert end of main routine. DON'T WRITE CODE BELOW!!! ***/

} /*** End of main routine. DO NOT MODIFY THIS TEXT!!! ***/

 

/* END ProcessorExpert */

/*!

** @}

*/

Outcomes