![]() |
Kinetis SDK v.1.2 Demo Applications User's Guide
Rev. 0
Freescale Semiconductor, Inc.
|
This demo application demonstrates how to use the ADC drivers with different hardware triggers.
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:
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.
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.
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.
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.
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.
These Freescale Freedom development platforms and Tower System modules are supported by the KSDK CADC Hardware Trigger demo.
For more detailed instructions, see a Kinetis SDK User's Guide for your board.
This demo application is customizable to show different kinds of input signal waves.
The configuration macro is located in the cadc_hw_trigger.h header file.
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.
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:
Change the following macro to configure the desired frequency in Hz units.
If you do not use the DAC0_OUT as a input signal, disable the macro in the project:
After disabling the DAC output, configure one ADC input source pin to get the signal: