Datasheet
30
LTC2400
TYPICAL APPLICATIONS
U
Sample Driver for LTC2400 SPI Interface
The LTC2400 has a very simple serial interface that makes
interfacing to microprocessors and microcontrollers very
easy. Shown in Figures 32 and 34 are listings of sample
source codes that can be used to initiate conversions and
retrieve data from the LTC2400.
The listing in Figure 32 was created by Parallax, Inc. (916-
624-8333), for the BASIC Stamp. This code uses indi-
vidual port lines to control the LTC2400’s conversion and
'LTC2400 Sample Driver
'03/17/99 This program is an example showing how to access the
' LTC2400 using the Basic Stamp2 from Parallax. Since
' the BS2 is based on a 16-bit architecture, only the
' upper 16 bits of the 24-bit result are displayed,
' although all 24 bits are retrieved.
ADlo var word 'A/D result - lower 16 bits
ADhi var word 'A/D result - upper 8 bits
Ctr var byte 'loop counter
Temp var bit 'temporary bit used for shift
SDO con 0 'Serial data connected to P0
SCK con 1 'Serial clock connected to P1
CS con 2 'Chip Select connected to P2
Pwr con 3 'Stamp supplies power connected to P3
'(Uses only 0.3mA!)
Init
dira = $E 'Set up data direction
'Pwr, CS, and SCK are outputs
'SDO is an input
outa = $0 'Initialize outputs
'Pwr, CS, and SCK are low
pause 100 'Wait 100mS for I/O to settle
high Pwr 'Power up the LTC2400
pause 1 'Wait 1mS for power-on sequence
high CS 'Disable the device until we
Start 'wish to read it.
pause 125 'Eight times second
low CS 'Enable the LTC2400
for Ctr = 0 to 31
high SCK 'Cycle clock 32 times
gosub ShiftL
retrieve the 32-bit result. A fourth port line is used to
power the LTC2400, a vivid example of the converter’s
micropower operation. The program’s main sequence
activates the LTC2400’s serial interface, uses a loop to
retrieve the 32 conversion bits, and then places the
converter’s interface in a high impedance state and start-
ing the next conversion. All bits are retained in variables
ADlo and ADhi. The code can be found on their web site,
www.parallaxinc.com.