Kinetis SDK v.1.2 Demo Applications User's Guide  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
demo_apps/adc_low_power/main.c File Reference
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include "fsl_debug_console.h"
#include "adc_low_power.h"
#include "fsl_smc_hal.h"
#include "fsl_pmc_hal.h"
#include "fsl_adc16_driver.h"
#include "board.h"

Macros

#define ADC_0
 
#define CHANNEL_0
 
#define LED_ON
 
#define LED_OFF
 
#define ADCR_VDD
 These values are used to get the temperature. DO NOT MODIFY The method used in this demo to calculate temperature of chip is mapped to Temperature Sensor for the HCS08 Microcontroller Family document (Document Number: AN3031) More...
 
#define V_BG
 
#define V_TEMP25
 
#define M
 
#define STANDARD_TEMP
 
#define UPPER_VALUE_LIMIT
 
#define LOWER_VALUE_LIMIT
 
#define UPDATE_BOUNDARIES_TIME
 
#define kAdcChannelTemperature
 
#define kAdcChannelBandgap
 

Functions

void init_trigger_source (uint32_t instance)
 Enable the trigger source of LPTimer. More...
 
void ADC1IRQHandler (void)
 ADC Interrupt handler. Get current ADC value and set conversionCompleted flag. More...
 
void config_vlps (void)
 enter in VLPS mode More...
 
void calibrateParams (void)
 Parameters calibration: VDD and ADCR_TEMP25. More...
 
static int32_t init_adc (uint32_t instance)
 Initialize the ADCx for HW trigger. More...
 
int32_t GetCurrentTempValue (void)
 Calculate current temperature. More...
 
lowPowerAdcBoundaries_t TempSensorCalibration (uint32_t updateBoundariesCounter, int32_t *tempArray)
 Calculate current temperature. More...
 
int main (void)
 main function More...
 

Variables

static volatile uint32_t adcValue
 
static uint32_t adcrTemp25
 
static uint32_t adcr100m
 
volatile bool conversionCompleted
 
SIM_Type * gSimBase []
 
static smc_power_mode_config_t smcConfig
 

Macro Definition Documentation

#define ADC_0
#define ADCR_VDD
#define CHANNEL_0
#define kAdcChannelBandgap
#define kAdcChannelTemperature
#define LED_OFF
#define LED_ON
#define LOWER_VALUE_LIMIT
#define M
#define STANDARD_TEMP
#define UPDATE_BOUNDARIES_TIME
#define UPPER_VALUE_LIMIT
#define V_BG
#define V_TEMP25

Function Documentation

void ADC1IRQHandler ( void  )
void calibrateParams ( void  )

Parameters calibration: VDD and ADCR_TEMP25

This function used BANDGAP as reference voltage to measure vdd and calibrate V_TEMP25 with that vdd value.

ADC value of BANDGAP

VDD in mV

void config_vlps ( void  )
int32_t GetCurrentTempValue ( void  )
Returns
uint32_t Returns current temperature.
static int32_t init_adc ( uint32_t  instance)
static
Parameters
instanceThe ADC instance number
void init_trigger_source ( uint32_t  adcInstance)

enable the trigger source of LPTimer

enable the trigger source

enable the trigger source of PIT0, chn0

enable the trigger source of LPTimer

enable the trigger source

enable the trigger source of PIT0, chn0

enable the trigger source of PWM

enable the trigger source of LPTimer

enable the trigger source

enable the trigger source of PIT0, chn0

enable the trigger source of PWM

int main ( void  )

Function prototype for main function.

lowPowerAdcBoundaries_t TempSensorCalibration ( uint32_t  updateBoundariesCounter,
int32_t *  tempArray 
)
Parameters
updateBoundariesCounterIndicate number of values into tempArray.
tempArrayStore temperature value.
Returns
lowPowerAdcBoundaries_t Returns upper and lower temperature boundaries.

Variable Documentation

uint32_t adcr100m
static

Calibrated ADCR_TEMP25

uint32_t adcrTemp25
static

ADC value

volatile uint32_t adcValue
static
volatile bool conversionCompleted
SIM_Type* gSimBase[]

Conversion is completed Flag

smc_power_mode_config_t smcConfig
static