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
ADC Hardware Trigger Demo

This demo application demonstrates how to use the ADC driver with various hardware triggers.

Overview

This is an ADC demo application which shows how to use different hardware trigger sources to handle the ADC hardware trigger function. These trigger sources are supported:

Trigger by PIT

The Periodic Interrupt Timer (PIT) is a period timer source and the ADC hardware trigger event. Because the PIT trigger event can only be used to trigger one of the ADC channels (mux A or B), this demo uses PIT as a trigger source for the ADCx channel 0. The PIT triggers the ADC in a fixed frequency and the demo gets the ADC conversion result in the ADC Conversion Complete (COCO) interrupt. TWR-KV10Z32 does not support PIT trigger, due to no PIT in KV10 silicon.

Trigger by PDB

The Programmable Delay Block (PDB) is a continuous trigger event for ADC. It uses the software trigger as the first trigger input event and turns on the PDB continuous mode to generate a period trigger source. Because the PDB can trigger different channels inside one ADC instance, this demo shows the Ping-Pong triggering which occurs by sampling the channel 0/1 with the PDB Pre-trigger A/B channel. FRDM-KL26Z and MRB-KW01 does not support PDB trigger, because PDB is not present neither on KL26 nor on KW01 silicon.

Trigger by LPTMR

The Low Power Timer (LPTMR) is a period timer source and the ADC hardware trigger event. Because the LPTMR trigger event can only be used to trigger one of the ADC channels (channel 0 or 1), this demo uses the LPTMR as a trigger source for the ADCx channel 0. The LPTMR triggers the ADC in a fixed frequency and the demo gets the ADC conversion result in the ADC Conversion Complete (COCO) interrupt.

Input signal for ADC

Use the DAC module to generate a sine wave as the ADC input on the DAC0_OUT pin. Normally, the DAC0_OUT is internally connected to the ADC0_SE23 (DAC0_OUT is a source of ADC0_SE23), there is no need to connect any external signals for this demo.

Boards listed below need external sine wave connected either because of lack of the DAC hardware feature support or lack of the SoC/Board signal connection support.

This demo samples the input digital signal from the ADC0_SE23 pin and records each sample point with the appropriate amplitude. After 2 period samples are complete, it prints out the rough shape of the signal wave on the debug console like a primitive oscilloscope.

Supported Platforms

These Freescale Freedom development platforms and Tower System modules are supported by the KSDK ADC Hardware Trigger demo.

The adc_lptmr_trigger demo Supported Platforms:

The adc_pdb_trigger demo Supported Platforms:

The adc_pit_trigger demo Supported Platforms:

The adc_tpm_trigger demo Supported Platforms:

System Requirement

Hardware requirements

Toolchain requirements

Software requirements

Getting Started

Hardware configuration

For the MRB-KW01: It is necessary to short jumpers J10 and J11 to connect the ADC references. If the ADCO_SE23 or internal DAC connection is used it is necessary to disconnect J7 to open PTE30 connection with the RESET of the RADIO part. Also analog function for PTE30 - DAC output is necessary on the mrb-kw01 (default is GPIO for RADIO part reset).

Prepare the Demo

  1. Connect a USB cable between the PC host and the OpenSDA USB port on the board.
  2. Open a serial terminal with these settings:
    • 115200 baud rate
    • 8 data bits
    • No parity
    • One stop bit
    • No flow control
  3. Download the program to the target board.
  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

For more detailed instructions, see a Kinetis SDK User's Guide for your board.

Run the demo

  1. Select and open one project from the four projects available: adc_pit_trigger, adc_lptmr_trigger and adc_pdb_trigger.
  2. Open the UART console on a PC and adc_tpm_trigger.
  3. Download and run the program on the target.
  4. The signal waveform is displayed on the console.

Customization Options

This demo application is customizable to show different kinds of input signal waves.

Default configurations

The configuration macro is located in the adc_hw_trigger.h header file.

ADC configurations

  1. Use ADC0 instance.
  2. Use ADC_SE23 input pin as sample pin.
  3. Use VREFH/L as reference voltage.

Sample frequency

The default sample rate is 1000 Hertz, which enables the demo application to get 100 samples per two periods. To change the sample rate, see the next section.

Configure the number of samples

Printing of the signal wave shape depends on the console size. A console can be 100x40. To get the best printing effect, align the number of samples to the console column numbers and convert the amplitude range to the [0, row - 1] range. The console column number should be same as sample numbers. Configuring the number of samples means configuring the console column size:

#define CHART_ROWS 30U // chart row for sampled data
#define CHART_COLS 100U // chart column for sampled data
#define NR_SAMPLES 100U // number of samples in one period

Configure the signal frequency

Change the following macro to configure the desired frequency in Hz units.

#define INPUT_SIGNAL_FREQ 20U // in Hz

Configure the ADC instance

Change the ADC_INST macro to configure the ADC instance you want to use.

#define ADC_INST 0U // ADC instance

Configure the ADC input pin

If you do not use the DAC0_OUT as a input signal, disable the macro in the project:

//#USE_DAC_OUT_AS_SOURCE

After disabling the DAC output, configure one ADC input source pin to get the signal:

#define ADC_INPUT_CHAN 23U // default input signal channel