This tutorial was extracted from Erich Styger blog http://mcuoneclipse.wordpress.com with his agreement.
In “IoT: FreeRTOS Down to the Micro Amps” I’m using an application with FreeRTOS to get down in micro amps low power mode. Well, nearly all or my applications are using FreeRTOS because it makes the application scalable and extensible. Still, for anyone not used to an RTOS, that might be a hard start. So here we go: how to get into the Kinetis Low Power LLS Mode *without* an RTOS.
Power Measurement
Outline
In this project I create a very simple bare-metal application for the Freescale FRDM-KL25Z board. All what it does is to blink an LED from the Low Power wake-up interrupt to show that the application is running. Right after the wake-up interrupt, it enters again the LLS low power mode. So I enter LLS low power mode, and the timer interrupt will wake me up every second. As in LLS mode only a few timer and wake-up sources are available, I’m going to use the 1 kHz Low Power clock source.
The project and all the settings is available on GitHub at the link provided at the end of this article.
Processor Expert Components
In this project, I’m using the following components:
- 3 LED components (RGB)
- TimerInt with TimerUnit_LDD for the low power wake-up timer
- WAIT component to flash different LED’s after power-up with a delay.
Processor Expert Components
Timer
As timer I use the LPTMR with a period of one second:
Low Power 1 Second Timer
Inside the period settings, I configure it to use the LPO 1 kHz timer as clock source, as this clock still will run in LLS mode:
LPO 1 kHz Source
CPU Component
First, we need to configure the CPU component to be ready for low power mode. I enable the methods SetOperationMode() and GetLLSWakupFlags() (so the black x is removed):
Enabled SetOperationMode and GetLLSWakeupFlags
In the CPU properties, I enable all low power modes, configure LPTMR0 as wake-up source, and enable the INT_LLW wake-up interrupt:
Enabled Low Power Modes
Then I configure the WAIT, SLEEP and STOP modes (these are the three different low power modes in Processor Expert):
WAIT, SLEEP and STOP modes
Source Files
Time to write the application code. I’m using Application.h and Application.c:
/*
|
The the Application.c looks like this:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
/*
|
From main() in ProcessorExpert.c I call APP_Run():
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
#include "PE_Types.h"
|
And from Events.c I call my hooks:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
/*
|
Summary
This application shows how to set up an application for Low Power LLS mode, in a bare-metal mode. So it should be useful for you if you want to have a starting point for your own project without an RTOS.
The project and sources are available on GitHub.
Top Comments