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

This demo application demonstrates how to use the ADC drivers with different hardware triggers.

Overview

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

Trigger by PIT

The Periodic Interrupt Timer (PIT) is a period timer source and the CADC hardware trigger event. Because the PIT trigger event can only be used to trigger one of the CADC, this demo uses PIT as a trigger source for the CADCx channel 4. The PIT triggers the CADC in a fixed frequency and the demo gets the CADC conversion result in the CADC Conversion Complete (COCO) interrupt.

Trigger by PDB

The Programmable Delay Block (PDB) is a continuous trigger event for CADC. It uses the software trigger as the first trigger input event and turns on the PDB continuous mode to generate a period trigger source. Channel 4 is scanned at every PDB trigger.

Trigger by LPTMR

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

Trigger by PWM

The Pulse Width Modulator (PWM) is a continuous trigger event for CADC. It uses the software start as the first trigger input event and turns on the PWM continuous mode to generate a trigger source in every PWM period. Channel 4 is scanned at every PWM trigger.

Input signal for ADC

Use the DAC module to generate a sine wave as the CADC input on the DAC0_OUT pin. The DAC0_OUT is taken on PTE30 and connected to the ADCA_CH4 through an on-board jumper.

This demo samples the input digital signal from the ADCA_CH4 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 CADC Hardware Trigger demo.

System Requirement

Hardware requirements

Toolchain requirements

Software requirements

Getting Started

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: cadc_pit_trigger, cadc_lptmr_trigger, cadc_pdb_trigger and cadc_pwm_trigger.
  2. Open the UART console on a PC.
  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 cadc_hw_trigger.h header file.

CADC configurations

  1. Use ADCA instance.
  2. Use ADCA_CH4 input pin as sample pin.
  3. Use VREFH/L as reference voltage.

Sample frequency

The default sample rate is 20 Hz * 100 / 2, 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 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 4U // default input signal channel