Datasheet

31
LTC2400
Figure 32. This BASIC Stamp Code is an Example of How Easy it is to Retrieve Data from the LTC2400
ADlo.bit0 = in0 'and sample data line
low SCK
next
high CS 'Disable the LTC2400
ADhi = (ADhi<<4)+((ADlo&$F000)>>12)
debug ?ADhi 'Discard the lower eight bits
goto Start 'and display (debug command).
ShiftL
Temp = ADlo.bit15 'This routine simply
ADlo = ADlo<<1 'performs a 1 bit
ADhi = ADhi<<1 'left shift on two
ADhi.bit0 = Temp '16 bit variables
return
TYPICAL APPLICATIONS
U
Figure 33. Connecting the LTC2400 to a 68HC11 MCU Using the SPI Serial Interface
LTC2400
SCK
SDO
CS
7
6
5
SCK (PD4)
MISO (PD2)
SS (PD5)
68HC11
2400 F33
The listing in Figure 34 is a simple assembler routine for
the 68HC11 microcontroller. It uses PORT D, configuring
it for SPI data transfer between the controller and the
LTC2400. Figure 33 shows the simple 3-wire SPI
connection.
The code begins by declaring variables and allocating four
memory locations to store the 32-bit conversion result.
This is followed by initializing PORT D’s SPI configuration.
The program then enters the main sequence. It activates
the LTC2400’s serial interface by setting the SS output
low, sending a logic low to CS. It next waits in a loop for
a logic low on the data line, signifying end-of-conversion.
After the loop is satisfied, four SPI transfers are com-
pleted, retrieving the conversion. The main sequence ends
by setting SS high. This places the LTC2400’s serial
interface in a high impedance state and initiates another
conversion.
*****************************************************
* This example program transfers the LTC2400's 32-bit output *
* conversion result into four consecutive 8-bit memory locations. *
*****************************************************
*68HC11 register definition
PORTD EQU $1008 Port D data register
* " – , – , SS* ,CSK ;MOSI,MISO,TxD ,RxD"
DDRD EQU $1009 Port D data direction register
SPSR EQU $1028 SPI control register
* "SPIE,SPE ,DWOM,MSTR;SPOL,CPHA,SPR1,SPR0"
SPSR EQU $1029 SPI status register
* "SPIF,WCOL, – ,MODF; – , – , – , – "
SPDR EQU $102A SPI data register; Read-Buffer; Write-Shifter
*
* RAM variables to hold the LTC2400's 32 conversion result