MKMxxZxxACxx5 Bare Metal Software Drivers  R4.1.6
Reference Manual
LLWU Periodical Wakeup Using LPTMR

This example shows typical use of LPTMR module for resuming device operation and exiting from standby modes on a periodical bases. The exit from VLLS1 mode is initiated via Low-Leakage Wakeup Unit (LLWU) and performed via device reset. Immediately after POR, the device enters very low power run (VLPR) mode with core clock = 2.0 MHz and bus/flash clock = 1.0 MHz. You can uncomment respective source line for entering into either VLLS3, VLLS2 or VLLS1 modes and to measure its power consumption.

Note
In order to download new software example enter and hold device in a reset state by asserting RESET_B pin followed by power cycling and initiating downloading new software example. When downloading is about to start de-assert RESET_B pin.
Source code:
/******************************************************************************
* (c) Copyright 2010-2015, Freescale Semiconductor Inc.
* ALL RIGHTS RESERVED.
******************************************************************************
* llwulptmr_test.c
******************************************************************************/
#include "drivers.h"
void main (void)
{
/* reset pin filtered in all modes and filter clocked by LPO */
/* enable low voltage reset detection (1.6V), disable interrupts and bandgap*/
/* initialize LPTMR and IRTC at POR; release I/O states otherwise */
else
{
}
/* LLWU initialize */
arch_delay (10000000l); /* VLPR=258uA @ 2:1:1 2MHz core clock */
/* main programme loop */
while (1)
{
/* enter low power mode */
//SMC_SetMode(VLLS3); /* VLLS3 = 1.8uA */
SMC_SetMode(VLLS2); /* VLLS2 = 1.6uA */
//SMC_SetMode(VLLS1); /* VLLS1 = 1.1uA */
}
}
Appconfig.h:
/******************************************************************************
* (c) Copyright 2010, Freescale Semiconductor Inc.
* ALL RIGHTS RESERVED.
***************************************************************************/
#ifndef __APPCONFIG_H
#define __APPCONFIG_H
/***************************************************************************/
//#define MTB_RAM_RESERVE
/***************************************************************************/
#define BOOT_NMI_DISABLE
#define BOOT_EXT_CLK
#define BOOT_SWVLPR_MODE
/***************************************************************************/
/******************************************************************************/
#endif /* __APPCONFIG_ */
Toolchain support:
IAR EWARM 7.40.7CodeWarrior 10.6KEIL uVision 5.15CrossWorks 3.6ATOLLIC TrueStudio 5.3.0Kinetis Design Studio 3.0.0