Application Note
AN114
-
1
AN114
Interfacing the X9408/X9418 XDCP to 8051 Microcontrollers
by Applications Staff,
This application note describes the routines for the control
of an X9408 or X9418 digitally controllable potentiometer.
The X9408/X9418 devices have a variety of different
instructions that provide flexibility to the designer.
Additionally, the nonvolatile nature of the device allows for
stored wiper positions that can be retrieved after power
cycles.
The following code implements all of the available X9408/
X9418 instructions using a standard bi-directional bus
protocol. Although the routines occupy less than 300
bytes of program memory, designers who won't need to
implement all of the instructions can shor ten the code by
removing any unnecessary routines. However, this will
necessitate the reassembly of the code .
For those instr uctions which program the nonvolatile data
registers (XFR_WCR, GXFR_WCR, & WRITE_DR),
acknowledge polling has been implemented to deter mine
an early completion of the internal write cycle. Although
this is automatically handled by the routines , a word or two
regarding the procedure should be informative. After
issuing a start condition, the master sends a slave
address and receives an acknowledge. It then issues an
instruction byte to the X9408/X9418 and again receives
an acknowledge. If necessary, it now transmits the data
byte and receives a final acknowledge. The master must
then initiate a stop condition which will cause the X9408/
X9418 to begin an internal wr ite cycle. The X9408/X9418
pins go to high impedance until this internal cycle is
complete. The master can no w begin acknowledge polling
by successively sending start conditions followed by
"dummy" instructions. When the X9408/X9418 finally
ans w ers with an ac kno wledge , the internal write cycle has
been completed. The master must then initiate a stop
condition. After the next start condition, the X9408/X9418
is ready to receiv e further instructions.
Figure 1. Connecting the X9408 to an 80C51 microcontroller
31
19
18
9
39
38
37
36
35
34
33
32
21
22
23
24
26
26
27
28
17
16
29
30
11
10
P0.0
P0.1
P0.2
P0.4
P0.5
P0.6
P0.7
P2.0
P2.1
P2.2
P2.3
P2.4
P2.5
P2.6
P2.7
RD
WR
PSEN
ALE/P
TXD
RXD
P0.3
3
4
5
6
7
8
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
2
1
12
13
14
15
INT0
INT1
T0
T1
RESET
X2
X1
EA/VP
5V
R?
10K R?
10K
3
4
2
VHO
VWO
VLO
10
11
9
VH1
VW1
VL1
15
14
16
VH2
VW2
VL2
21
22
23
VH2
VW2
VL2
24
13
V+
V-
+5V
-5V
U?
17
7SCL
SDA
19
18
5
8
20
X940880C51
VSS
A3
A2
A1
A0
P1.0
P1.1
Xicor Application Note
AN114-2
AN114
In the code listing, an assumption was made that the code
executes upon a reset of the microcontroller. That is, the
code is loaded into low memory, however this can be
changed with an ORG assembler directive. A simple
MAIN program to e x ercise these routines is included in the
code listing. In this listing, the commands cause an
X9408/X9418 (at A3A2A1A0 = 0000) to be accessed and
the WCR of EEPOT #2 to be rewritten with the value 43
(f or wiper tap position #43). Then a 15 pulse decrement of
the wiper tap is initiated, causing the selected WCR to be
reduced to the v alue 28 (for wiper tap position #28).
The issuing of other commands follows the same
general procedure. In Figure 1, a representative
hardware connection between the X9408 and an 8051
family microcontroller is shown. The pull-up resistors on
the SDA and SCL lines are determined by the total
capacitance of all of the devices connected to the bus,
which is about 18pF. in this case, however these may
not be necessary since I/O port pins on 8051 family
de vices hav e internal pull-ups.