Low power mode

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

Low power mode

2,682 Views
haroldvogel
Contributor II

I am new to Code Warrior and Processor Expert.  I need to setup the MKL36Z256VLL4 chip to go into low power but wake up every 200 milliseconds so that I can check status and perform any requested functions.  The product does not have an operating system but just a loop to scan through tasks that it needs to do.  Would like to know how to set this up with Processor Expert or if I don't need Processor Expert and just code the WFI and clock to wake up every 200 milliseconds to check and perform tasks.

0 Kudos
9 Replies

1,207 Views
haroldvogel
Contributor II

I thought that I had responded to this message but I guess I did not.

The information though interesting does not seem to fit the CPU that I am using.  The Starting Point for Kinetis Low Power LLS Mode | MCU on Eclipse does not display the same information that I have.  I don't show a WAIT1:Wait in the components list and I have not found in any of the components that are a LLWU settings.  Nor do I find any of the files that are shown under the CPU.  I believe that I stated that I am using the MKL36Z128 and 256VLLL4.

We have no operating system just a loop that goes and polls all items.

I need to put the unit in a sleep state and wake up every few milliseconds to check status and then perform operations that are needed and then go back to sleep until the next time out.

I hope that some one can help me with this problem.

0 Kudos

1,207 Views
haroldvogel
Contributor II

CPU_Pic0.PNGCPU_Pic1.PNGCPU_Pic2.PNGCPU_Pic3.PNGCPU_Pic4.PNG

Here are images of the CPU clock information.  Which seems to go along with the information or at least some of the information above, but I still don't know how to put the CPU into a sleep mode where it will wake up every few milliseconds to poll the system perform tasks and then go back to sleep.

0 Kudos

1,207 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Harold Vogel:

In a new project only the Cpu component is included by default. You need to add all the components you need from the Components LIbrary. Just from the Alphabetical tab search the components you need and double click on them or [Right click -> Add to project]:

pastedImage_2.png

Then you should be able to replicate the instructions in the tutorial for your KL36. The exception to this is the WAIT component, which as mentioned is not a component developed by NXP (formerly Freescale), so it is not part of Processor Expert by default but instead is provided externally by colleague Erich Styger. I believe the blog post that explains this is the next:

McuOnEclipse Releases on SourceForge | MCU on Eclipse

In any case the WAIT component is not strictly required, for testing purposes you could add a dummy software delay with a for loop.

Regards!

Jorge Gonzalez

0 Kudos

1,207 Views
haroldvogel
Contributor II

I was wondering and hoping that you could give me more information on how to setup the TimerUnit_LDD to have it wake up the unit from a WAIT/STOP mode?  Currently, I believe, the code is using Timer for some other function.  There is also a TestTimer:TimerUnit_LDD but I am not sure what is being or was being used for in the code.  The code has no documentation telling what it was to be used for either.  It seems to be using the same timer that you have referenced in your post.

0 Kudos

1,207 Views
haroldvogel
Contributor II

I found the following:

Chapter 33

Low-Power Timer (LPTMR)

33.1 Introduction

NOTE

For the chip-specific implementation details of this module's

instances, see the chip configuration information.

The low-power timer (LPTMR) can be configured to operate as a time counter with

optional prescaler, or as a pulse counter with optional glitch filter, across all power

modes, including the low-leakage modes. It can also continue operating through most

system reset events, allowing it to be used as a time of day counter.

33.1.1 Features

The features of the LPTMR module include:

• 16-bit time counter or pulse counter with compare

• Optional interrupt can generate asynchronous wakeup from any low-power mode

• Hardware trigger output

• Counter supports free-running mode or reset on compare

• Configurable clock source for prescaler/glitch filter

• Configurable input source for pulse counter

• Rising-edge or falling-edge

33.1.2 Modes of operation

The following table describes the operation of the LPTMR module in various modes.

KL36 Sub-Family Reference Manual, Rev. 3, July 2013

I could not a reference (or at least what I found did not indicate this register) to this register.  What I read seems to indicate that it will do what I wish, in that the unit can go into a low power state and wake up on a timer and then be put back into a low power state.  Just need to find out how to do this.  I hope that you or someone can help me with this.

0 Kudos

1,207 Views
haroldvogel
Contributor II

For more information, below is the current code:

void Enter_Power_Save(void)

{

     shutdownIO();

     while(1)

     {

          enter_lls();

          // Do a partial restoration of I/O, enough to read the state of /ACOK

          SIM_SCGCS |= SIM_SCGCS_PORTB_MASK;

          PORTB_PCR7 |= (uint32_t)(PORT_PCR_MUC(MUC_GPIO));

          Delay_ms(200);

          if ( RUNNING_FROM_BATTERY )

          {

               PORTB_PCR7 &= ~(uint32_t)(PORT_RCR_MUX(MUX_MASK));

               SIM_SCGCS &= ~(SIM_SCGCS_PORTB_MASK);

          }

          else

          {

               break;

          }

     }

}

void Exit_Power_Save(void)

{

     restoreIO();

}

void enter_lls(void)

{

     SMC_PMCTRL &= ~SMC_PMCTRL_STORM_MASK;

     SMC_PMCTRL |= SMC_PMCTRL_STORM(0X3);

     SMC_PMCTRL;

     deepsleep();

}

void deepsleep(void)

{

     SCB_SCR |= SCB_SCR_SLEEPDEEP_MASK;

     asm("WFI");

     resetTracking.processor_wakeup++;

}

From what I have been told when the WFI interrupt occurs the resetTracking.processor_wakeup++ is triggered and the code returns to where the power down function was called.

What I would lie to do is put in a check to see if we are in another mode which would allow the unit to go to sleep or wait and when a timer triggered it would wake up and perform a task and then go back to sleep?

0 Kudos

1,207 Views
haroldvogel
Contributor II

I can find no information on the SystemControl_BASE_PTR, which is the register that is being used to put the unit in DEEP SLEEP.  Is there a way to configure this register to wake up on a timer when the unit goes to sleep?  If there is such a way then how is it done.

0 Kudos

1,207 Views
haroldvogel
Contributor II

Hello Jorge,

This is a project that I took over for another person and we are expanding the functionality of the product.  One of the things that I have to do is to put the system in a sleep state which it will wake up every few milliseconds and poll the system to see if anything needs to be done.

I was looking over the information that you have sent the MCU on Eclipse showed a similar display as I posted in my last message but did not explain how to set up the MCU to go to sleep and wake up do a timer.  Nor does any of the other PDF files show how to set up the code to have the unit go to sleep and wake up when a timer has expired.

0 Kudos

1,207 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Harold Vogel:

For starters you can look at the next great tutorial to wake the MCU from Low Power mode (in this case LLS mode) with the Low Power Timer (LPTMR):

:smileyinfo: Heads up: Wait is not part of the default PE components, it is part of a set of components provided by colleague Erich.

Starting Point for Kinetis Low Power LLS Mode | MCU on Eclipse

In the next document you can read a quick explanation of low power modes with Processor Expert:

Operation modes in Processor Expert

As you will see the linked tutorial uses the LLS mode, but you might decide on a different mode. In case you want to learn more about Kinetis Low Power modes there are the next application notes:

AN5088: Power Management for Kinetis L family

AN4470: Using Low Power modes on Kinetis family

AN4503: Power Management for Kinetis MCUs

I hope this helps.


Best Regards!
Jorge Gonzalez

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

0 Kudos