User`s manual
XP8500
40 s Software Reference
int adc4
_
set( unsigned int board
_
adr,
int chan )
Sets the A/D converter chip to the specified channel (chan).
PARAMETERS: board
_
adr is the physical address of the XP8500
board, defined as 0000 1100 ppxy.
chan ranges from 0 to 10, corresponding to the boards 11 A/D
channels. Passing chan = 11 will return (VREF+ VREF)/2,
passing chan = 12 will return VREF, passing chan = 13 will return
VREF+, and passing chan = 14 will put the boards A/D chip, a
TLC2543, into software power-down mode. All data defaults to 12
bits unipolar mode with MSB first. The returned datas nominal zero
point is 4095 for unipolar conversion and 2047 for bipolar conversion.
RETURN VALUE: whole number from 0 to 4095 from the last A/D
conversion (caller should be aware of which A/D channel was set
previously); 1 if the specified XP8500 board cannot be found.
Because the A/D converter chip is hardwired to return a
converted value while accepting new settings, adc4
_
set
returns a value converted with the chips previous settings.
Therefore, subsequent calls to adc4
_
set using the same
arguments will return conversions using the new settings.
The key to understanding the difference between adc4
_
read
and adc4
_
set is the pipelined nature of the A/D converter.
By design, shifting a command into the A/D converter simulta-
neously shifts a reading out. However, the A/D converter
made this shifted-out reading according to the previous
commands setup.
So to return a correct reading for a single function call, the
adc4
_
read command shifts a command into the A/D con-
verter, discards the resulting reading, and makes a second read
from the now properly set up A/D converter. The faster
adc4
_
set
function simply returns the first reading. Succeed-
ing adc4
_
set calls will return proper readings with the same
arguments.
!