AN114 Xicor, AN114 Datasheet

no-image

AN114

Manufacturer Part Number
AN114
Description
Interfacing the X9408/X9418 XDCP to 8051 Microcontrollers
Manufacturer
Xicor
Datasheet

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
AN1149FHKEBV
Manufacturer:
PANASONIC/松下
Quantity:
20 000
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-direc-
tional bus protocol. Although the subroutines occupy
about 300 bytes of program memory, designers who
won't need to implement all of the instructions can
shorten the code by removing any unnecessary routines.
However, this will necessitate the reassembly of the
code.
REV 1.1 11/12/02
Interfacing the X9408/X9418 XDCP to 8051 Microcontrollers
39
38
37
36
35
34
33
32
12
13
17
10
14
15
11
16
19
18
31
Figure 1. Connecting the X9408 to an 80C51 microcontroller
9
U1
80C51
P0.0
P0.1
P0.2
P0.3
P0.4
P0.5
P0.6
P0.7
INT0
INT1
RD
RXD
T0
T1
TXD
WR
X1
X2
EA/VP
RST
Application Note
ALE/P
PSEN
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
P2.0
P2.1
P2.2
P2.3
P2.4
P2.5
P2.6
P2.7
+5V
1
2
3
4
5
6
7
8
21
22
23
24
25
26
27
28
30
29
by Applications Staff,
10K
R1
www.xicor.com
R2
10K
For those instructions which program the nonvolatile
data registers (XFR_WCR, GXFR_WCR, &
WRITE_DR), acknowledge polling has been imple-
mented to determine 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 acknowl-
edge. 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 condi-
tion which will cause the X9408/X9418 to begin an
internal write cycle. The X9408/X9418 pins go to high
impedance until this internal cycle is complete. The
17
18
20
19
7
5
8
U2
X940
SCL
SDA
A3
A2
A1
A0
VSS
8
VW0
VW1
VW2
VW3
VCC
VH0
VH1
VH2
VH3
VL0
VL1
VL2
VL3
V+
V-
3
4
2
10
11
9
15
14
16
22
21
23
1
24
13
-5V
AN 114
1 of 12

Related parts for AN114

AN114 Summary of contents

Page 1

... P1 P1.1 3 P1.2 4 P1.3 5 P1.4 6 P1.5 7 P1.6 8 P1.7 21 P2.0 22 P2 P2 ALE/P 29 PSEN www.xicor.com U2 3 SCL VH0 4 SDA VW0 2 VL0 10 VH1 11 VW1 9 VL1 15 VH2 14 VW2 16 VL2 22 A3 VH3 21 A2 VW3 23 A1 VL3 A0 1 VCC VSS V- X940 8 -5V AN 114 ...

Page 2

... These can be modified for different device addresses, different registers and different DCPs within the device. 80C51 MICROCONTROLLER ROUTINES FOR MANIPULATING AN X9408 ;----------------------------------------------------------------------------- ; ; 80C51 MICROCONTROLLER ROUTINES FOR MANIPULATING AN X9408 ; QUAD EEPOT ; ; (C) XICOR INC. 2002 ; ; ; FILE NAME : X9408_8051.TXT ; TARGET MCU: Cygnal C8051F000 ; DESCRIPTION: ...

Page 3

... Bits -> DATA_BYTE equ r7 ; Bits -> ;----------------------------------------------------------------------------- ; Constant Definition ;----------------------------------------------------------------------------- SLAVE_ADR0 equ 050h SLAVE_ADR1 equ 051h SLAVE_ADR2 equ 052h SLAVE_ADR3 equ 053h SLAVE_ADR4 equ 054h SLAVE_ADR5 equ 055h SLAVE_ADR6 equ 056h REV 1.1 11/12/02 Application Note www.xicor.com AN 114 ...

Page 4

... READDR equ 8 WRITEDR equ 12 XFRDR equ 16 XFRWCR equ 20 GXFRDR equ 24 GXFRWCR equ 28 INCDECWIPER equ 32 ;----------------------------------------------------------------------------- ; INTERNAL RAM ;----------------------------------------------------------------------------- STACK_TOP equ 060H ; Stack top ;----------------------------------------------------------------------------- ; RESET and INTERRUPT VECTORS ;----------------------------------------------------------------------------- cseg AT 0 ljmp main REV 1.1 11/12/02 Application Note ; Locate a jump to the start of code at www.xicor.com AN 114 ...

Page 5

... WCR to one of its data registers ; gxfr_drGlobal transfer of data registers to WCRs ; gxfr_wcrGlobal transfer of WCRs to Data Registers ; inc_wiperSingle Step Increment/Decrement of wiper position for WCR ; REV 1.1 11/12/02 Application Note Switch to this code segment. Specify register bank for the following program code. www.xicor.com AN 114 ...

Page 6

... Jump to the addr for this instruction call instr_gen ret gxfr_dr: mov a,ID ; Get bits orl a,#010h ; Append to the GXFR DR instruction code mov ID Save the result mov dptr,#case4 ; Jump to the addr for this instruction call instr_gen ret REV 1.1 11/12/02 Application Note www.xicor.com AN 114 ...

Page 7

... If program gets here, then it is done case2: mov a,DATA_BYTE ; Send X9408 data byte call send_byte jmp stop_gen case1: call get_byte ; Receive X9408 Data Byte jmp stop_gen case3: mov a,DATA_BYTE ; Send X9408 Data Byte call send_byte REV 1.1 11/12/02 Application Note www.xicor.com AN 114 ...

Page 8

... FUNCTION: Places a bit on SDA and initiates a clock pulse on SCL ; INPUTS OUTPUTS: NONE ; CALLS: clock ; AFFECTED: SDA ; ;----------------------------------------------------------------------------- send_bit: clr SDA ; Pull SDA Low jz sent_zero ; Should SDA really be LOW? setb SDA ; If Not, pull SDA HIGH sent_zero: call clock ; Initiate a clock pulse ret ;----------------------------------------------------------------------------- ; REV 1.1 11/12/02 Application Note www.xicor.com AN 114 ...

Page 9

... AFFECTED: SDA, SCL ; ;----------------------------------------------------------------------------- start_cond: setb SDA ; Pull SDA HIGH and allow set-up setb SCL ; Pull SCL HIGH and hold nop nop nop nop clr SDA ;Pull SDA LOW (SCL=HIGH) and hold nop nop nop nop REV 1.1 11/12/02 Application Note www.xicor.com AN 114 ...

Page 10

... INPUTS: ADDR_BYTE ; OUTPUTS: NONE ; CALLS: start_cond, send_byte ; AFFECTED ;----------------------------------------------------------------------------- polling: call START_COND ; Re-establish I2C protocol mov a,ADDR_BYTE ; Attempt to send a dummy command again: call SEND_BYTE jc POLLING ; If C=1, then there was no ACK ret REV 1.1 11/12/02 Application Note www.xicor.com AN 114 ...

Page 11

... COMMAND, #READWCR; Read WCR call execute ; WCR value is in DATA_BYTE write_2_dr: mov ADDR_BYTE, #SLAVE_ADR12; Load Slave address byte mov ID, #DCP2_R1; Specify DR#1 for DCP#2 mov COMMAND, #WRITEDR; Write to DR mov DATA_BYTE, #21; Set data value to 21 call execute REV 1.1 11/12/02 Application Note www.xicor.com AN 114 ...

Page 12

... PULSES, #0Fh; Decrement DCP#2 for 16 pulses mov COMMAND, #INCDECWIPER; INC wiper call execute incr_wiper: mov ADDR_BYTE, #SLAVE_ADR12; Load Slave address byte mov ID, #WCR_2 ; Select DCP#2 mov PULSES, #8Fh; Increment DCP#2 for 16 pulses mov COMMAND, #INCDECWIPER; DEC wiper call execute END REV 1.1 11/12/02 Application Note www.xicor.com AN 114 ...

Related keywords