Application Note AN-877
Rev. B | Page 17 of 20
PROGRAMMING EXAMPLE
Programming tools are available to assist in the development of
code for SPI devices. A user may wish to access the features
available with SPI control, but not have access to a full featured
SPI controller. If this is the case, consult the AN-812
Application Note for a low cost alternative to a full featured
controller.
A software tool is also available (see www.analog.com/FIFO) for
controlling the devices used on the corresponding evaluation
board. This tool allows the registers to be configured to determine
the optimal device configuration for the end application. In
addition, once this process is complete, the software tool
generates two files useful for programming the devices. The
first file format is a pseudocode format.
This can be added to a C language project to set up the appro-
priate writes and reads to ensure the device is configured per
the settings in the evaluation software. To use this pseudocode,
the user need only supply the hardware-specific read and write
functions associated with their SPI controller. The example
code in this section outlines a sample program sequence for the
devices.
The second file format is assembly code that can be used with
the microcontroller described in the AN-812 Application Note.
(See AN-812 for additional details on the usage of this output.)
For additional details on using these tools, see the AN-878
Application Note, High Speed ADC SPI Control Software.
write(0, 18); //configure serial interface for MSB first
//set Devices-Index to program ADC Channels 0 and 1
//set vref to option 2 and adjustment to all zeros
write(14, 10);
//set output_mode to level option 0, disable output MUX, enable output and
offset binary
//set output_delay to enable and set to delay value of 3
//write transfer bit (for configurations that require a manual transfer)
//set Device-Index to program ADC Channel 1
//set offset to 3 (for Channel 1 only)
//write transfer bit (for configurations that require a manual transfer)
//set Devices Index to program ADC Channel 2
//set offset to 9 (for Channel 2 only)
//write transfer bit (for configurations that require a manual transfer)