MKMxxZxxACxx5 Bare Metal Software Drivers  R4.1.6
Reference Manual
LLWU Pin Falling Edge Wakeup

This example shows typical use of the Low-Leakage Wakeup Unit (LLWU) to exit selected VLLSx mode via reset condition. The software example allows selection of the STOP, VLPS, VLLS3, VLLS2, VLLS1 or VLLS0 mode for device wakeup.

Source code:
/******************************************************************************
* (c) Copyright 2010-2015, Freescale Semiconductor Inc.
* ALL RIGHTS RESERVED.
******************************************************************************
* llwu_test.c
******************************************************************************/
#include "drivers.h"
/* Button definitions */
#define BTN_VLPS_WKUP PIN0 /* PTD0; SW1 on TWR-KM34Z50M */
#define LED PIN1 /* PTD1; LED3 on TWR-KM34Z50M */
/* Callback function declaration */
static void port_callback (PORT_CALLBACK_SRC src, uint8 pin);
/******************************************************************************/
void main (void)
{
0);
PORT_Init (PORTD, PORT_MODULE_BUTTON_IRQ_MODE, BTN_VLPS_WKUP);
GPIO_Init (GPIOD, GPIO_INP_MODE, BTN_VLPS_WKUP);
if (PMC_GetACKISO()) { PMC_SetACKISO (); } /* release I/O states */
/* install PORTx interrupt */
PORT_InstallCallback (PRI_LVL3, port_callback);
/* toggle LED to notify reset condition */
GPIO_Clr (GPIOD, LED);
arch_delay (5000000l);
GPIO_Set (GPIOD, LED);
arch_delay (5000000l);
/* main programme loop */
while (1)
{
// SMC_SetMode(STOP); /* IDD=311.1uA, IBAT=1.9uA */
// SMC_SetMode(VLPS_PSTOP1); /* IDD= 5.0uA, IBAT=1.9uA */
// SMC_SetMode(VLPS_PSTOP2); /* IDD= 5.0uA, IBAT=1.9uA */
SMC_SetMode(VLPS); /* IDD= 4.9uA, IBAT=1.9uA */
// SMC_SetMode(VLLS3); /* IDD= 1.9uA, IBAT=1.9uA */
// SMC_SetMode(VLLS2); /* IDD= 1.8uA, IBAT=1.9uA */
// SMC_SetMode(VLLS1); /* IDD= 1.3uA, IBAT=1.9uA */
// SMC_SetMode(VLLS0_POR_ON ); /* IDD= 0.7uA, IBAT=1.9uA */
// SMC_SetMode(VLLS0_POR_OFF); /* IDD= 0.4uA, IBAT=1.9uA */
}
}
/* callback functions */
void port_callback (PORT_CALLBACK_SRC src, uint8 pin)
{
if (src == PORTD_CALLBACK)
{
if (pin == BTN_VLPS_WKUP)
{
GPIO_Clr (GPIOD, LED);
arch_delay (1000000l);
GPIO_Set (GPIOD, LED);
}
}
}
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
/***************************************************************************/
/******************************************************************************/
#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