| Online Development Notebook > Index > U4x1 Application Notes > App8: SPI ADC |
App8: SPI ADC
Purpose
Provide a program that interfaces to an analog to digital converter through the SPI port. This example uses the LTC1298, a 12 bit two channel ADC.
Description
This program initializes thirteen i⁄o lines of the U401⁄U421⁄U451 to be outputs, and enables the SPI subsystem. The LTC1298, a 12 bit serial (SPI) A⁄D device, is connected to the MISO, MOSI, and CLK lines, as well as one of the output lines. The program selects the ADC device, selects channel 0, and reads the converted analog value. This is repeated for channel 1.
See this small list of SPI devices for other SPI A⁄D devices.
Screen Shot
Below is the application screen reading some A⁄D values.

Hardware
The data sheet for the LTC1298 was followed for connection to the U4x1 device. Bypass capacitors are not shown in the schematic.
Pin 1 of the LTC1298 is the active low chip select and is controlled by port A.4. MOSI of the U4x1 (A.5) connects to the A⁄D "D in" to send a command to the A⁄D, while MISO (A.6) reads the data from "D out". The SPI clock (A.7) connects to pin 7, the LTC1298's clock line.

Code
Download all application files: (all application files)
| Hardware: U401 USB Interface U421 USB Interface U451 USB Interface Programming: USBm DLL Programming Download Files Application Notes: U4x1 Application Notes Misc Applications and Information FAQ While every effort has been made to make sure that the information posted on this site is correct, the author can not be held liable for any damages whatsoever for losses as a result of the application of this information. Use this information at your own risk. USBmicro can design your custom and semi-custom USB product. Email about USB design can be directed to " Robert " at usbmicro.com. Copyright © USBmicro, L.L.C., 2002-2010 |