BL4S100 User’s Manual
92
anaInDriver
int anaInDriver(char cmd);
FUNCTION DESCRIPTION
Low-level driver to read the ADS7870 A/D converter chip. Reads the voltage of an an-
alog input channel by serial clocking an 8-bit command to the ADS7870 by its Direct
Mode method.
anaInConfig()
uses the Register Mode method. This function call
assumes that Mode2 (least significant byte first) and the A/D converter oscillator have
been enabled.
See anaInConfig() for additional setup information.
After the last data bit is transferred, the conversion begins immediately. An exception
error will occur if Direct Mode bit D7 is not set.
PARAMETER
cmd
The
cmd
parameter contains a gain code and channel code, and the
MSB is set high for direct-mode access. The format is as follows:
Use the following calculation and tables to determine
cmd
:
cmd = 0x80 | (gain_code<<4) + channel_code
D7
D6–D4
D3–D0
1
gain_code
channel_code
gain_code
Multiplier
0
1
1
2
2
4
3
5
4
8
5
10
6
16
7
20