OneTechnologyWay•P. O . Box9106•Norwood,MA02062-9106,U.S.A.•Tel : 781.329.4700•Fax :781.461.3113•www.analog.com
ADP8860 Software User Guide
INTRODUCTION
This user guide describes the functionality of the Analog
Devices, Inc., ADP8860 and provides software development
guidelines. The ADP8860 communicates with an external
processor using an I
2
C interface and an interrupt line (nINT).
The processor sends initialization and activation commands
to the ADP8860, which acts as a slave device.
The interrupt line, from the ADP8860 to the processor, is used
to indicate a failure condition, such as a thermal shutdown or
an overvoltage and LED/output short circuit, or to indicate a
V
OUT
light level threshold has been crossed. All interrupt sources are
maskable. Refer to Figure 1 for a typical application diagram.
Figure 2 shows a schematic with keypad light control.
The interrupt line is active low; each interrupt source has an
individual masking bit. The processor can reset the ADP8860
anytime by pulling the nRST line low; this operation reinitializes the ADP8860 at the default state and places the device
in standby mode.
OPTIONAL
PHOTOSENSOR
ALS
PHOTOSENSOR
0.1µF
0.1µF
V
A2
A1
C1
B1
B2
C1+
C1–
C2+
C2–
1µF
OUT
C1
1µF
C2
1µF
08158-001
V
nRST
SDA
SCL
nINT
IN
1µF
VDDIO
VDDIO
VDDIO
VDDIO
D3D1E3D2E4D3D4D4C4D5B4
A3
E1
ADP8860
C2
E2
D2
A4
GND1
D6/
CMP_IN2
D1
GND2
D7C3CMP_IN
B3
Figure 1. Typical Application Schematic with Optional Second Photo Diode
Rev. 0 | Page 1 of 44
UG-005 Software User Guide
TABLE OF CONTENTS
ADP8860 Software User Guide ...................................................... 1
Listing for ADP8860_Regs.h .................................................... 31
Listing for ADP8860 Constants.h ............................................ 36
Listing for ADP8860 Reset.h .................................................... 38
Listing for ADP8860 MainProgram.c...................................... 39
Rev. 0 | Page 2 of 44
Software User Guide UG-005
KEYPAD LIGHT
UP TO 10 LEDs (6mA EACH)
60mA MAX TOTAL CURRENT
VDDIO
I
CONTRO L
SIGNALS
V
IN
R1 R2 R3 R4
nRST
2
C
nINT
1µF
DISPLAY BACKLI GHT
DL1
DL2
DL3
D3
E3
D1
VIN
A3
GND1
A4
D1
GND2
nRST
E1
SDA
C2
SCL
E2
nINT
D2
E4
D2
D3
Figure 2. Schematic with Keypad Light Control
DL4
D4
D4
ACCESSORY
LIGHTS OR
SUB-DISPLAY BL
DL5
DL6
C4
B4
D5
D6/
CMP_IN2
ADP8860
DL7R5DL8
R6
B3
D7C3CMP_IN
VOUT
C1+
C1–
C2+
C2–
DL17
R15
2.8V
PH2
OPTIONAL
PHOTOSENSOR
0.1µF
A2
A1
C1
B1
B2
1µF
C1
1µF
C2
1µF
PH1
MAIN
PHOTOSENSOR
0.1µF
08158-002
Rev. 0 | Page 3 of 44
UG-005 Software User Guide
I2C INTERFACE MODE
The ADP8860 includes an I2C-compatible serial interface for
controlling the LED current, as well as for readback of system
status registers. The I
2
C device address is 0x54 (0101 0100,
binary) for a write sequence and 0x55 (0101 0101, binary) for
a read sequence. Figure 3 shows the I
2
C write sequence while
Figure 4 shows a read operation.
B7B0B7B0B7B0
STACKREGISTER ADDRESSACKREGISTER VALUE
0101010
R/W
The ADP8860 sends data from the register denoted by the
register address. The lowest bit number (0) represents the least
significant bit, and the highest bit number (7) represents the
most significant bit. The register address content selects which
of the ADP8860 registers data is written to or read from.
ACK
ST
START
SLAVE TO MASTER
MASTER TO SLAVE
DEVICE ID
0x54 FOR WRI TE
OPERATIO N
SELECT ADP8860 REGISTER TO
WRITE I N THE 0x00 TO 0x24 AND
WRITE = 0
FROM ADP8860
0x2E RANGE
Figure 3. I
2
C Write Operation
8-BIT VALUE TO WRITE IN THE
ADDRESSED REGIST ER
FROM ADP8860
FROM ADP8860
STOP
08158-003
B7B0B7B0B7B0
ST
DEVICE ID
0x54 FOR WRI TE
START
OPERATION
SLAVE TO MASTER
MASTER TO SLAVE
R/W
ACKREGISTER ADDRESSACKACKREGISTER VALUEACK0101010
SELECT ADP8860 REGISTER TO
WRITE I N THE 0x00 TO 0x24 AND
WRITE = 0
FROM ADP8860
0x2E RANGE
Figure 4. I
B7B0
RS0101010
DEVICE ID
0x55 FOR READ
OPERATION
FROM ADP8860
REPEATED START
2
C Read Operation
R/W
8-BIT VALUE TO WRITE IN THE
READ = 1
ADDRESSED REGIST ER
FROM MASTER
ST
STOP
08158-004
Rev. 0 | Page 4 of 44
Software User Guide UG-005
INTERRUPTS
There are up to five interrupt sources available on the ADP8860
as follows:
• CMP_INT is from the main light sensor comparator.
• CMP2_INT is from sensor Comparator 2.
• OVP_INT is from the overvoltage protection comparator.
• TSD_INT is from the thermal shutdown circuit.
• SHORT_INT is from the short-circuit detection
comparator.
Each interrupt has individual masking/enable bits mapped in
Register INTR_EN. If the respective bit in the masking register
is 0, an interrupt is not generated to the external processor,
however the interrupt pending bit (on the MDCR2 register) can
be set in case the monitored condition occurs. This can be used
by the processor to periodically poll the interrupt pending
register (Register MDCR2) looking for an event to be true. If
the masking register bit is 1 an interrupt is generated (the nINT
line goes low) to the external processor in case an interrupt
pending bit is set.
CMP_INT is set every time the main light sensor comparator
detects a threshold transition (rising or falling condition). This
comparator has two programmable thresholds (L2 and L3)
defining the transition level from dark to office (L3) and from
office to outdoor (L2).
The CMP2_INT interrupt works the same way as CMP_INT
except that the sensing input comes from the second light
sensor. The programmable threshold is the same as the main
light sensor comparator.
The OVP_INT interrupt is generated when the charge pump
output voltage rises above a safety limit. In the event of an over-
voltage condition, the charge-pump is disabled until the output
voltage decreases to a recovery working level. An overvoltage
event can be generated when the load is removed from the
circuit and the input voltage, multiplied by the charge pump
gain (can be 1.5× or 2×), is above the OVP limit. In this condition, the interrupt to the external processor is generated
periodically. Therefore, the software should handle a case of
this sort by turning off the ADP8860 or disabling the OVP
interrupt mask.
The TSD_INT interrupt is generated when the die temperature in
the ADP8860 rises above a safety limit, typically 150°. When this
condition occurs, the charge pump and the LED drivers are turned
off waiting for the die to cool down. When the die temperature
decreases below ~130° the circuit is activated again automatically.
No interrupt is generated when the device turns on again, however
if the software clears the pending interrupt and the temperature
remains above 130° another interrupt is generated.
The SHORT_INT interrupt is generated if the output of the
charge-pump VOUT is shorted to ground or an LED connected
to the sink output is shorted. In a short-circuit event, the charge
pump and drivers are turned off immediately and the shortcircuit pending flag is set. The processor may then retry new
activations or issue a diagnostic message. Interrupts are cleared
by writing a 1 in the pending register bit. If Bit INT_CFG in
Register MDCR is set to 1, this forces the nINT line deassertion
(Logic High) for 50 μs after the processor clears the interrupt
pending, and the interrupt condition persists. If INT_CFG is 0,
the nINT line remains asserted (Logic Low) after the processor
clears the interrupt pending and the interrupt condition
persists.
MDCR (0x01)
BIT 6
INT_CFG
50µs
INT
INTERRUPT
DE-ASSERTI ON
INT_CLEAR
(ASSERTED WHEN WRITING
THE INTERRUPT PENDING
FLAGS I N MDCR2)
BIT 4BIT 3BIT 2BIT 1BIT 0
SHORT_IENCMP_IENCMP2_IENOVP_IENTSD_IEN
SHORT_INT TSD_INTOVP_INT CMP2_INT CMP_INT
BIT 4BIT 3BIT 2BIT 1BIT 0
Figure 5. Interrupt Logic
Rev. 0 | Page 5 of 44
INTR_EN (0x03) – INTERRUPT MASKS
MCDR2 (0x02) – INT ERRUPT PENDING
08158-005
UG-005 Software User Guide
DATA FLOW DIAGRAMS
Figure 6 and Figure 7 show the backlight data flow and the individual data flow, respectively.
NSTBY = 0
OR VIN < UVLO
TURN OFF
BACKLIGHT
AND ISINKS
STANDBY
BLEN = 0
OR TSD_INT = 1
OR SHORT_INT = 1
NSTBY = 1
NO COMMAND
BLEN AND
FOVR = 1
FADE IN
TO DIM
BLEN = 1
BL_FO TIMEOUT
WAITING
COMMAND
DIM_EN AND
BLEN = 1
BACKLIGHT
DIM STATE
(OFFT)
BACKLIGHT
FADE IN
TO MAX
BL_FI TIMEOUT
DIMT = DISABL ED
BACKLIGHT
ACTIVATIO N
TIME (DIMT)
DIM_EN = 1
AND DIMT TIM EOUT
BACKLIGHT
NOTES
1. DASHED LINE INDICATES AN INTERRUPT O R AN EVENT THAT CAN HAPPEN ANYTI ME DURING THE DEVICE O PERATION.
2. COMMANDS FRO M I
COMMANDS TO MAKE THE FLOW REPRES ENTATION CLEARER.
2
C ARE ALWAYS MO NITORED AND EXECUTED. T HE FLOW SHOWS A COMMON BUBBLE FOR
NSTBY = 0
DIM_EN = 0
AND DIMT = DISABL ED
OFFT TIMEOUT
AND DIM_EN = 0
DIM_EN = 1 OR
OFFT = DISABLED
BACKLIGHT
OFF
BL_FO TIMEOUT
BACKLIGHT
FADE OUT
Figure 6. Backlight Data Flow
TO OFF
08158-006
Rev. 0 | Page 6 of 44
Software User Guide UG-005
OR TIMEOUT
SCx OFF = 0
(ALWAYS ON)
ACTIVATIO N
INDIVIDUAL
xSINK
TIMEOUT
SCFI = 0
SCON
NSTBY = 0
OR VIN < UVLO
BACKLIGHT
AND ISINKS
xSINK
FADE-IN
FADE-OUT
TURN OFF
STANDBY
NSTBY = 1
NO COMMAND
WAITING
SCx_EN = 1
SCx OFF
TIMEOUT
SCx_EN = 0SCx_EN = 0
xSINK
COMMAND
TURN OFF
INDIVIDUAL
SCFO = 0
OR TIMEOUT
SINK
NSTBY = 0
SIS_EN = 1
AND ISCC = 0
ENABLED
SINKS
FADE-IN
OR TIMEOUT
xSINK
SCFO = 0
OR TIMEOUT
SCFI = 0
SCx_EN = 0
OR TSD_INT = 1
OR SHORT_INT = 1
OFF
ENABLED
SINKS
FADE-OUT
ACTIVATE
ENABLED
SIS_EN = 0
OR ISCC ≠ 0
SINKS
SIS_EN = 1
AND ISCC = 0
NOTES
1. DASHED LINE INDICATES AN INTERRUPT O R AN EVENT THAT CAN HAPPEN ANYTI ME DURING THE DEVICE OPERATION.
Figure 7. Individual Sinks Data Flow
Rev. 0 | Page 7 of 44
08158-007
UG-005 Software User Guide
SETTING THE LED CURRENT
The ADP8860 contains seven current sink outputs that can be
software configured to operate as part of the LED backlight or
as individual sinks, such as funlights or keypad lights. All
outputs can drive up to 30 mA with the exception of the seventh
sink (D1B/LED7) that can drive up to 60 mA, which is ideal for
keypad light applications where up to 10 LEDs can be driven in
parallel with shunt resistors (see Figure 2).
The application software must program which output to use as
part of the backlight and which to use for the individual sinks.
Register BLSEN is used for this purpose. If the selection bit
associated with the LED sink (Bit 0 controls LED1, Bit 1
controls LED2, and so on) is set to 0, it is part of the LED
backlight; otherwise, if set to 1, it is an independent sink. In
this case, Register ISCC controls the individual sink turn-on
and turn-off activations. For example, if BLSEN is programmed
with 0x70, LED1 to LED4 are used for the backlight while LED5
to LED7 are individual sinks. Bit 7 in BLSEN is not used.
In backlight operation, there are three distinct selectable brightness levels: dark, office, and daylight. Each brightness level has
two programmable settings:
•The MAX brightness defined in Register BLMX1 (day-
light), Register BLMX2 (office), and Register BLMX3
(dark) can range from 0 mA to 30 mA.
•The DIM brightness level defined in Register BLDM1 for
daylight, Register BLDM2 for office, and Register BLDM3
for dark can range from 0 mA to 30 mA.
The backlight LED current depends on the backlight transfer
law, linear or square, programmed in the CFGR register Bit 2
and Bit 1. Tabl e 2 shows all the current values available
according to the control law selected.
The transfer function for the linear law is
__
ISCALEFULL
⎞
⎟
⎠
RegValue
⎛
_
RegValueIBACKLIGHT (1)
= (2)
×=
⎜
⎝
IBACKLIGHT
127_ ×
ISCALEFULL
__
127
where:
BACKLIGHT_I is the desired LED current in mA.
RegValue is the digital 7-bit value programmed in the backlight
current registers.
FULL_SCALE_I is the maximum backlight current value, which
is 30 mA.
The transfer function for the square law is
2
⎞
__Re
ISCALEFULLgValue
(3)
⎟
⎟
⎠
RegValue
⎛
⎜
_
=
IBACKLIGHT
⎜
⎝
=
×
127
IBACKLIGHT
_127 ×
(4)
ISCALEFULL
__
Table 1. Backlight Transfer Laws—CFGR Register Bits[2:1]
Bits[2:1] Fading Law Fading Time Change
00 Linear Law DAC Linear time steps
01 Square Law DAC Linear time steps
10
11
Square Law DAC
(Cubic 1)
Square Law DAC
(Cubic 2)
Nonlinear time steps
(Type 1)
Nonlinear time steps
(Type 2)
The complete set of square law current values are given in
Tabl e 2.
If the automatic light sensing control is enabled (CMP_AUTOEN,
Bit 1, is set to 1 in Register MDCR) the result from the light
sensing comparator controls the backlight brightness in one of
the three levels (dark, office, and daylight).
In this mode, it is not possible to force, by software, a defined
level. Thus, settings on Bits[4:3] (BLV) in the CFGR register are
not considered in automatic light sensing mode. In case the
automatic light sensing mode is disabled (0 is written to
CMP_AUTOEN in the MDCR register), software can force the
backlight brightness in one of the three possible modes (dark,
office, or daylight) by writing Bits[4:3] (BLV) in Register CFGR
(see Tabl e 3).
Table 3. Brightness Level—Bits[4:3] (BLV) in CFGR Register
Each individual sink has a dedicated current register defining
its brightness level. As with the backlight, the current level
depends on the transfer law selected in the ISCFR register
Bits[1:0] (SC_LAW).
The ISC1 register defines the current level for LED1, the ISC2
register defines the level for LED2, and so on until ISC7, which
controls the current for LED7. The maximum current level
programmable is 30 mA. However, LED7 can be set up to
60 mA if Bit 7 in the ISC7 register is set to 1. The possible
current levels for 30 mA are listed in Tab le 2 .
Rev. 0 | Page 11 of 44
UG-005 Software User Guide
Table 4. Complete Set of Square Law Current Values for LED7
—60 mA Range
Square Cubic Law 1 and Square Cubic Law 2 use the same
square transfer law values with faster increment/decrement
times when fading in and out.
FADE OVERRIDE MODE
The fade override mode is enabled when Bit 0 (FOVR) in the
CFGR register is set to 1. In this mode, the backlight skips the
fade-in time when Bit BLEN in the MDCR register is set to 1
and it goes directly to the programmed maximum backlight
35
30
25
20
15
LED CURRENT (mA)
10
5
0
020406080100120
Figure 8. LED Current Transfer Law Curves
LINEAR LAW
SQUARE LAW
DIGITAL VALUE (DAC)
brightness intensity. There remains a 100 ms ramp-up time to
avoid rapid change in current. The fade-in time is not skipped
at the very first activation, after an off condition.
This mode is useful is situations where the backlight is fading
out and the user depresses a keypad button. The system
software can intercept this condition, set the FOVR bit, then
write the BLEN bit to 1 again. Fade-out time is not affected by
the FOVR bit.
08158-008
Rev. 0 | Page 14 of 44
Software User Guide UG-005
SETTING BACKLIGHT AND SINK TIMINGS
The LED backlight supports several programmable timing
controls as described in this section.
Note that the following equation is only for linear step control
laws:
CONTROLLING BACKLIGHT SETTINGS
Bits[3:0] of the BLFR register set the backlight fade-in time (see
Tabl e 5). The time specified in Ta ble 5 is from the maximum
allowable current level (30 mA) to zero. Equation 5 gives an
estimated value for the actual fade-in time based on known
conditions. If the value programmed is zero, the fade-in time is
disabled, however a 100 ms fade-in time is used.
Bits[7:4] of the BLFR register set the backlight fade-out time,
(see Tabl e 5). Equation 6 gives an estimated value for the actual
fade-in time based on known conditions. If the value programmed is zero, the fade-out time is disabled, however a 100 ms
fade-in time is used.
Bits[6:0] of the BLDIM register set the time for the backlight
to stay in the MAX brightness state. After this time, the backlight starts to fade out to the DIM or zero level (If the DIM
timeout is disabled). The digital value programmed in this
register corresponds to the time in seconds. For example,
BLDIM = 0x32 corresponds to 50 seconds.
Bits[6:0] of the BLOFF register set the time for the backlight
to stay in the DIM state. After this time, the backlight starts to
fade out to zero current level. The digital value programmed in
this register corresponds to the time in seconds. For example,
BLOFF = 0x10 corresponds to 16 seconds.
Table 5. Backlight Fade-In (Bits[3:0]) and Fade-Out
(Bits[7:4]) Times
BLFR Register Value Fade-In and Fade-Out Time (Sec)
MaxCurr is the maximum backlight current value programmed
in the BLMXx registers.
ActualCurr is the initial backlight current (0 mA at the first
activation).
T
is the calculated fade-in time in seconds.
FADE _ES T
Note that the following equation is only for linear step
control laws:
MinCurrActualCurrOutFade
T
= (6)
_
ESTFADE
30
−×
)(_
where:
ActualCurr is the backlight current value and can be MaxCurr if
fading out from the MAX brightness state or DimCurr if fading
out from DIM state.
MinCurr is the backlight current value and can be DimCurr if
fading out from the MAX brightness to DIM state or zero if
fading out from DIM state to zero current.
T
is the calculated fade-out time in seconds.
FADE _ES T
CONTROLLING SINK SETTINGS
The enabled individual sinks have dedicated registers to control
the activation timings and fade-in, fade-out times. The activation on time for Sink 1 to Sink 7 is selected by Register ISCT1,
Bits[7:6] and is common for all the individual sinks (see
Tabl e 6).
The off time is selected individually for each individual sink
(Sink 1 to Sink 7) by Register ISCT1, Bits[5:0] and Register
ISCT2, Bits[7:0] (see Table 7). Two bits are used per individual
sink. If the off time, 2-bit register is set to zero, the individual
sink is activated indefinitely.
The off time is controlled on each individual sink as follows:
ISCT1 Bits[5:4] for Sink 7, ISCT1 Bits[3:2] for Sink 6, ISCT1
Bits[1:0] for Sink 5, ISCT2 Bits[7:6] for Sink 4, ISCT2 Bits[5:4]
for Sink 3, ISCT2 Bits[3:2] for Sink 2 and ISCT2 Bits[1:0] for
Sink 1.
Table 6. Individual Sinks On-Time Selection
ISCT1 Bits[7:6] Programmed On Time (Sec)
00 0.2
01 0.6
10 0.8
11 1.2
Rev. 0 | Page 15 of 44
UG-005 Software User Guide
Table 7. Individual Sinks Off-Time Selection
Two-Bit Register Programmed Off Time (Sec)
00 Always on
01 0.6
10 1.2
11 1.8
Bits[3:0] of the ISCF register set the individual sinks fade-in
time (see Tab le 8). The time specified in Tabl e 8 is from zero
to the maximum allowable current level (30 mA or 60 mA for
Sink 7). Equation 5 gives an estimated value for the fade-in time
based on the actual programmed LED current. If the value
programmed is zero, the fade-in time is disabled; however, a
100 ms fade-in time is used.
Bits[7:4] of the ISCF register set the individual sinks fade-out
time (see Tab le 8). The time specified in Tabl e 8 is from the
maximum allowable current (30 mA or 60 mA for Sink 7) to
zero current. Equation 6 gives an estimated value for the fadeout time based on actual programmed LED current. If the value
programmed is zero, the fade-out time is disabled; however, a
100 ms fade-in time is used.
Table 8. Individual Sinks Fade-In and Fade-Out Times
Register Value Fade-In and Fade-Out Time in Seconds
The ADP8860 supports two light sensing inputs. The first light
sensing input is always dedicated as input from a phototransistor assessing the ambient light condition. The second light
sensing input is shared with Sink 6. Thus, the software must
carefully select the desired operation (light sensing or Sink 6).
Bit 5 (CMP2_SEL) in the CFGR register is used to configure pin
D6 (LED6) operation. If CMP2_SEL is 0, Pin D6 is an output
sink for LED6. If CMP2_SEL is set to 1, Pin D6 is an input from
the second light sensor (phototransistor). An internal analogto-digital converter processes the light information coming
from the light sensors providing a digital value corresponding
to the ambient light detected. The digital value is compared to
two thresholds (L2 and L3) to determine if the ambient light
condition is in one of the following three ranges:
Dark: Ambient light level is below L3 and L2 thresholds.
•
•
Office: Ambient light level is above L3, but below L2
thresholds.
•
Daylight: Ambient light level is above L3 and L2
thresholds.
Software can program the ADP8860 to operate in automatic
mode if Bit 1 (CMP_AUTOEN) in the MDCR register is set
to 1 or in manual mode, if CMP_AUTOEN is 0. When the
device operates in automatic light ambient mode, the backlight
brightness level is set by the current ambient light condition
(dark, office, and daylight).
Bit 0 and Bit 1 in CCFG and CCFG2 allow selection of the level
(L2 and/or L3) used for the automatic brightness control. If
both bits are 0, no automatic control is issued (see Table 9 ).
Software must program the desired levels for the L2 and L3
thresholds in the L2_TRP and L3_TRP registers, respectively.
Using the default phototransistor, the correlation factor between
programmed value and light level is provided in Table 10.
Table 9. Comparators Auto Level Control
Code Comparator Operation
00 No automatic brightness control
01 L2 comparator auto level control
10 L3 comparator auto level control
11 L2 and L3 auto level control
Table 10. Correlation Between Code and Phototransistor Lux
Measurement
Threshold Registers 1-Bit Correlation
L2 L2_TRP, L2_HYS 10 lux or 4 μA
L3 L3_TRP, L3_HYS 1.25 lux or 0.5 μA
Each threshold has an associated register setting the hysteresis
level to avoid changes due to noise or being too close to the
threshold. Each light sensor has an individual comparator and
control register.
Tabl e 11 shows the filter settings for the comparators. The
comparator filter makes sure that rapid changes in the ambient
light level do not change the backlight brightness.
Table 11. Comparators Filter Settings—Bits[7:5] in CCFG
and CCFG2
Every time the L2 or L3 threshold is crossed (rising or falling
conditions), a pending flag is set in the interrupt pending
register (MDCR2). Bit 0 (CMP_INT) is the flag for the first
light sensor while Bit 1 (CMP2_INT) is the flag for the second
light sensor. An interrupt is generated if the respective Interrupt
Enable bit is 1 in the INTR_EN register (or the CMP_IEN
register for light Sensor 1 and the CMP2_IEN register for light
Sensor 2).
The comparator interrupt can be useful in case the manual
backlight brightness level mode of operation is used so that
the software can read the comparator(s) outputs and force the
backlight brightness level through Bit BLV in the CFGR register.
See Tab l e 12 for the complete comparator output decoding.
The PH1LEVL, PH1LEVH, PH2LEVL, and PH2LEVH registers
contain the raw 13-bit conversion result for the first and second
light sensors. These registers can be used for diagnostic or
monitoring purposes. In typical applications, these registers can
be ignored.
The ambient light comparators have hysteresis thresholds
(L2_HYS and L3_HYS) added to the respective tripping
registers (L2_TRP and L3_TRP) to avoid the backlight mode
changes because of noise.
AMBIENT LIGHT INTENSITY
(LUX)
Figure 10 shows how the backlight mode of operation is
changed when the ambient light intensity varies.
Note that when the automatic light control mode and the
backlight are activated the first time, the state machine converts
the information coming from the phototransistor immediately
(takes roughly 82 ms to perform the conversion). The comparator result is then used to set the backlight intensity without
waiting for the comparator filter result. This avoids abrupt
brightness changes due to the filter delay calculating a
new value.
When the comparator is programmed to control the backlight
intensity (setting Bit CMP_AUTOEN in the MDCR register),
Bits[4:3] (BLV) in the CFGR register are modified with the
backlight operating state. Tab le 13 shows the decoding for
CFGR Bits[4:3] and CMP_AUTOEN Bit 1. When using this
table, note that R/W indicates a read/write register and R
indicates a read only register.
In some cases, more than one bit is used to define a subregister
function. For example, two bits define the LAW in the CFGR
register. To present the data structure in a simpler format, the
C language structure has been adopted. For example, the
structure presented in this user guide defines the subregister
field and dimension.
#define _CFGR 0x04 /* This is the Configuration Register */
struct reg_0x04 {
unsigned FOVR : 1; /* This is Bit 0 */c
unsigned LAW : 2; /* This is Bit 1 and Bit 2 */
unsigned BLV : 2; /* This is Bit 4 and Bit 3 */
unsigned CMP2_SEL : 1; /* This is Bit 5 */
unsigned SEL_AB : 1; /* This is Bit 6 */
};
Now the register can be defined and used as follows:
struct reg_0x04 cfgr; /* Associate cfgr variable with the specific structure */
cfgr.LAW = 2 /* Write LAW bits only */
Note the following regarding this code:
•
A colon is used to define a range of bits in one specific
register. For example, BLFR[7:4] specifies the upper four
bits in the BLFR register.
•
In general, variables appear in lowercase while constants
appear in uppercase.
•
Hexadecimal numbers are specified with the 0x prefix. For
example, 0x40 corresponds to 64 in decimal notation.
•
Decimal numbers are the default notation and can also be
specified with a postfix of dec, as in 120dec.
•
Binary numbers are specified with a postfix of b as in
00110101b. This corresponds to the hexadecimal number
0x35.
Rev. 0 | Page 19 of 44
UG-005 Software User Guide
FUNCTIONAL FLOWCHARTS
SET_BACKLIG HT_TIMING
SET_LEDS_MODES
WRITE BACKLI GHT AND
INDIVIDUAL SINK SELECTION
IN BLSEN REGI STER
SELECT WHET HER LED6 IN AN
INDIVIDUAL SINK OR INPUT FOR
THE 2ND PHOTOT RANSISTOR IN
CFGR REGIST ER (CMP2_SEL)
WRITE ZERO IN
BLDIM REGIST ER
EXAMPLE:
BLSEN = 01110000b
LED1 TO LED4 ARE PART OF
THE BACKLIGHT
LED5 TO LED7 ARE INDIVIDUAL
SINKS
EXAMPLE:
cdgr.CMP2_SEL = 0
LED6 IS AN INDI VIDUAL SINK
WRITE BACKLIGHT OFF
TIME-OUT PERIOD IN
BLOFF REGISTER
0 = DISABLED (AL WAYS
IN DIM STATE)
YES
FADE_LOCK?
WRITE BACKLI GHT DIM
TIME-OUT PERIOD IN
BLDIM REGISTER
WRITE BACKLI GHT FADE-IN
TIME IN BLFR[3:0] REGIST ER
(ZERO = FADE-IN DI SABLED)
WRITE BACKLIG HT FADE-OUT
TIME IN BLFR[7:4] REGISTER
(ZERO = F ADE-OUT DISABLED)
END
NO
EXAMPLE:
BLOFF = 5DEC
BACKLIGHT W ILL STAY AT THE DI M
LEVEL FOR 5 SECONDS THEN WILL
FADE-OUT TO ZERO.
FADE_L OCK IS A CUSTO MER REQUIREM ENT
WHERE THE BACKLIGHT FADE OUT FROM
THE MAX CURRENT LEVEL TO ZERO WITHOUT
RESTING AT THE DIM LEVEL. DIM _EN IN THE
MDCR REGISTER OVERRIDES A
FADE_L OCK CONDITI ON.
EXAMPLE:
BLDIM = 30DEC
BACKLIGHT W ILL BE ACTIVATED F OR
30 SEC THEN WILL FADE-OUT TO
DIM LEVEL.
EXAMPLE:
blfr.BL_FI = 0110b
BACKLIGHT F ADE-IN IN 1.8 SEC. THIS
TIME IS FULL-SCALE TO ZERO. IF THE
PROGRAMMED CURRENT IS DIFFERENT
OR GOING FROM MAX TO DIM OR DIM TO
ZERO, THE ACTUAL FADE-IN TIME
IS SHORTER.
EXAMPLE:
blfr.BL_FO = 1100b
BACKLIGHT F ADE OUT IN 4 SEC.
THIS TIME IS FULL-SCALE TO ZERO. IF THE
PROGRAMMED CURRENT I S DIFFERENT
OR GOING FROM MAX TO DIM OR DIM
TO ZERO, THE ACTUAL FADE-OUT TIME
IS SHORTER.
END
NOTES
1. IF BOT H BLDIM AND BLOFF ARE SET TO ZERO, THE ACT IVATION IN THE MAX AND DIM STATES
IS CONTROL LED BY THE PROCESSOR BY SET TING THE BLEN AND DIM_EN BIT S IN THE MDCR REGISTER.
Figure 11. Set Backlight Timing Flowchart
Rev. 0 | Page 20 of 44
08158-011
Software User Guide UG-005
SET_LEDS_CURRENT S
EXAMPLE:
SET BACKLIG HT CURRENT
LAW IN CFGR REGISTER
(LAW)
SET INDIVI DUAL SINKS
CURRENT LAW IN I SCFR
REGISTER (SC_LAW)
SET BACKLIG HT MAX
CURRENT LEVEL
(DAYLIGHT MODE)
IN BLMX1 REGI STER
SET BACKLIGHT DIM
CURRENT LEVEL
(DAYLIGHT MODE) IN
BLDM1 REGISTER
cfgr.LAW = 0
LINEAR LAW DAC
EXAMPLE:
iscfr.SC_LAW = 3
SQUARE LAW CUBI C 2 DAC
USE TABLE 2 TO GET THE CURRENT VALUE
BASED ON THE DIGITAL VALUE
PROGRAMMED I N BLMX1 AND THE
CONTRO L LAW SELE CTED.
USE TABLE 2 TO GET THE CURRENT VALUE
BASED ON THE DIGITAL VALUE
PROGRAMMED I N BLDM1 AND THE
CONTRO L LAW SELE CTED.
SET BACKLIG HT MAX
CURRENT LEVEL
(OFFICE MODE) IN
BLMX2 REGISTER
SET BACKLIGHT DIM
CURRENT LEVEL
(OFFICE MODE) IN
BLDM2 REGISTER
SET BACKLIG HT MAX
CURRENT LEVEL (DARK MODE)
IN BLMX3 REGI STER
SET BACKLIGHT DIM
CURRENT LEVEL (DARK MODE)
IN BLDM3 REGI STER
SET INDIVIDUAL SINKx
MAX CURRENT LEVEL IN
ISCx REGIS TER
USE TABLE 2 TO GET THE CURRENT VALUE
BASED ON THE DIGITAL VALUE PROGRAMMED
IN BLMX2 AND THE CO NTROL LAW SEL ECTED.
USE TABLE 2 TO GET THE CURRENT VALUE BASED
ON THE DIGITAL VALUE PROGRAMMED IN BLDM2
AND THE CONTROL LAW SELECTED.
USE TABLE 2 TO GET THE CURRENT VALUE
BASED ON THE DIGITAL VALUE PROGRAMMED
IN BLMX3 AND THE CO NTROL LAW SEL ECTED.
USE TABLE 2 TO GET THE CURRENT VALUE
BASED ON THE DIGITAL VALUE PROGRAMMED
IN BLDM3 AND THE CO NTROL LAW SELE CTED.
ONLY THE USED INDIVIDUAL SINK CURRENT
REGISTERS MUST BE INITIALIZED. ASSUMING
LED4 TO LED7 ARE SELECTED AS INDIVIDUAL
SINKS THEN REGISTERS ISC4 TO ISC7 NEED TO
BE INITIAL IZED. EACH REGIST ER CAN BE
PROGRAMMED AT DIFFERENT CURRENT LEV ELS.
FOR BIT 7 I N ISC7, SELECT 0mA T O 60mA RANGE
(IF SET ) OR 0mA TO 30mA (IF CLE ARED).
END
Figure 12. Set LEDs Currents Flowchart
Rev. 0 | Page 21 of 44
08158-012
UG-005 Software User Guide
SET_ISINKS_TIMING
WRITE INDIVIDUAL SINKS
ON-TIME IN ISCT1[7:6]
REGISTER
WRITE INDIVIDUAL SINK1
OFF-TIME IN ISCT2[1:0]
REGISTER
(ZERO = ALWAYS ON)
WRITE INDIVIDUAL SINK2
OFF-T IME IN ISCT2[3: 2]
REGIS TER
(ZERO = ALWAYS ON)
WRITE INDIVIDUAL SINK3
OFF-T IME IN ISCT3[5:4]
REGISTER
(ZERO = ALWAYS ON)
NOTE: THIS FLOW ASSUMES THAT ALL THE LEDS
ARE USED AS INDIVIDUAL SINKS. DISREGARD
INDIVIDUAL S INK(S) WRITE OPERAT ION FOR THOSE
LEDS USED AS BACKLI GHT.
EXAMPLE:
isct1.SCO N = 11b
INDIVIDUAL SINKS ON-TIME IS 1.2 SEC.
EXAMPLE:
isct2.SC1O FF = 01b
INDIVIDUAL SINK 1 OFF-TIME IS 0.6 SEC.
EXAMPLE:
isct2.SC2O FF = 01b
INDIVIDUAL SINK 2 OFF-TIME IS 0.6 SEC.
EXAMPLE:
isct2.SC3O FF = 01b
INDIVIDUAL SINK 3 OFF-TIME IS 0.6 SEC.
WRITE INDIVIDUAL SINK4
OFF-T IME IN ISCT2[7: 6]
REGIS TER
(ZERO = ALWAYS ON)
WRITE INDIVIDUAL SINK5
OFF-TIME IN ISCT1[1:0]
REGISTER
(ZERO = ALWAYS ON)
WRITE INDIVIDUAL SINK6
OFF-TIME IN ISCT1[3:2]
REGISTER
(ZERO = ALWAYS ON)
WRITE I NDIVIDUAL SINK7
OFF-TIME IN ISCT1[5:4]
REGISTER
(ZERO = ALWAYS ON)
WRITE I NDIVIDUAL SINKS
FADE-IN TI ME IN ISCF[3:0]
REGISTER
(ZERO = FADE -IN DISABLED)
WRITE INDIVIDUAL SINKS
FADE-OUT TIME IN ISCF[7:4]
REGISTER
(ZERO = F ADE-OUT DISABLED)
EXAMPLE:
isct2.SC4O FF = 01b
INDIVIDUAL SINK 4 OFF-TIME IS 0.6 SEC.
EXAMPLE:
isct2.SC5O FF = 00b
INDIVIDUAL SINK 5 IS ALWAYS ON.
EXAMPLE:
isct2.SC6O FF = 11b
INDIVIDUAL SINK 6 OFF-TIME IS 1.8 SEC.
EXAMPLE:
isct2.SC7O FF = 11b
INDIVIDUAL SINK 7 OFF-TIME IS 1.8 SEC.
EXAMPLE:
iscf.SCFI = 0011b
INDIVIDUAL SINKS FADE-IN IN 0.9 SEC.
THIS TIME IS FULL-SCALE TO ZERO. IF THE
PROGRAMMED CURRENT IS DIFFERENT, T HE
ACTUAL FADE-I N TIME IS SHORTER.
EXAMPLE:
iscf.SCFO = 0111b
INDIVIDUAL SINKS FADE-OUT IN 2.1 SEC.
THIS TIME IS FULL-SCALE TO ZERO. IF THE
PROGRAMMED CURRENT IS DIFFERENT THE
ACTUAL FADE-O UT TIME IS SHORT ER.
END
Figure 13. Set ISINKS Timing Flowchart
Rev. 0 | Page 22 of 44
08158-013
Software User Guide UG-005
ACTIVATE_BACKL IGHT
AUTOMATIC BACKL IGHT
BRIGHTNESS LEVEL?
YES
DISABLE FO RCED BACKLIGHT
BRIGHTNESS L EVEL.
cfgr.BLV = 3
NO
SELECT FO RCED BACKLIGHT
BRIGHTNESS LEVEL.
BITS BLV[1:0] IN CFGR
BRING DEVICE OUT OF
STANDBY.
mdcr.NSTBY = 1
ENABLE BACKLIGHT
mdcr.BLEN = 1
BACKLIGHT F ADE-IN
OVERRIDE?
YES
ENABLE BL OVERRIDE
cfgr.FO VR = 1
EXAMPLE:
cfgr.BLV = 0 (DAYLIGHT)
0 = DAYLIGHT, 1 = OFFICE, 2 = DARK
NO
DISABLE BL OVERRIDE
cfgr.FO VR = 0
NORMAL BL OPERATION
cfgr.DIM_EN = 0
NO
FORCE BACKLIG HT
AT DIM BRIGHTNESS
LEVEL?
YES
FORCE BL DIM
cfgr.DIM_EN = 1
NO
COMMAND
EXECUTED?
YES
END
Figure 14. Activate Backlight Flowchart
Rev. 0 | Page 23 of 44
08158-014
UG-005 Software User Guide
TURN_OFF_BACKL IGHT
YES
BACKLIGHT FO RCED
TO DIM LEVEL ?
NO
mdcr.BLEN = 0
ENTER IN
STANDBY?
YES
mdcr.NST BY = 0
END
NO
Figure 15. Turn Off Backlight Flowchart
08158-015
Rev. 0 | Page 24 of 44
Software User Guide UG-005
ACTIVATE_I NDIVIDUAL_SINKS
YES
TURN ON
ISINK 1?
NO
iscc.SC1_EN = 0iscc.SC1_EN = 1
YES
TURN ON
ISINK 2?
NO
iscc.SC2_EN = 1iscc.S C2_EN = 0
YES
TURN ON
ISINK 3?
NO
iscc.SC3_EN = 1iscc.S C3_EN = 0
YES
TURN ON
ISINK 4?
NO
iscc.SC4_EN = 1iscc.S C4_EN = 0
YES
TURN ON
ISINK 5?
NO
iscc.SC5_EN = 1iscc.S C5_EN = 0
YES
TURN ON
ISINK 6?
NO
iscc.SC6_EN = 1iscc.S C6_EN = 0
YES
TURN ON
ISINK 7?
NO
iscc.SC7_EN = 1iscc.S C7_EN = 0
YES
iscc = 0?
NO
IF D6 IS SELECTED AS
SECOND PHOTOTRANSISTOR,
THIS STEP SHOULD BE SKIPPED.
YES
SYNCHRONIZED
INDIVIDUAL S INKS
ACTIVATIO N?
YES
mdcr.SIS_EN = 1
NO
END
Figure 16. Activate Individual Sinks Flowchart
Rev. 0 | Page 25 of 44
08158-016
UG-005 Software User Guide
TURN_OFF _INDIVIDUAL_SINKS
NO
TURN OFF
ISINK 1?
YES
iscc.SC1_EN = 0
NO
TURN OFF
ISINK 2?
YES
iscc.SC2_EN = 0
NO
TURN OFF
ISINK 3?
YES
iscc.SC3_EN = 0
NO
TURN OFF
ISINK 4?
YES
iscc.SC4_EN = 0
NO
TURN OFF
iscc.SC5_EN = 0
NO
TURN OFF
iscc.SC6_EN = 0
NO
TURN OFF
iscc.SC7_EN = 0
ISINK 5?
YES
ISINK 6?
YES
ISINK 7?
YES
YES
iscc = 0?
NO
IF D6 IS SELECTED AS
SECOND PHOTO TRANSISTOR,
THIS STEP SHOULD BE SKIPPED.
YES
SYNCHRONIZED
INDIVIDUAL S INKS
ACTIVATIO N?
YES
mdcr.SIS_EN = 0
NO
END
Figure 17. Turn Off Individual Sinks Flowchart
Rev. 0 | Page 26 of 44
08158-017
Software User Guide UG-005
SETUP_INTERRUPTS
mdcr.INT_CFG = 0
intr_en .CMP_IEN = 0
intr_en. CMP2_IEN = 0
NO
NO
NO
NO
INTERRUPT
MASKED 50µs WHEN
CLEARED
OPTION?
YES
mdcr.INT_CFG = 1
ENABLE LIGHT
SENSING
COMPARATOR 1
INTERRUPT?
YES
intr_en. CMP_IEN = 1
ENABLE LIGHT
SENSING
COMPARATOR 2
INTERRUPT?
YES
intr_en. CMP2_IEN = 1
ENABLE
OVER-VOLTAGE
DETECTIO N
INTERRUPT?
intr_en.OVP_IEN = 0
NO
intr_en. TSD_IEN = 0
NO
intr_en. SHORT_IEN = 0
Figure 18. Setup Interrupts Flowchart
YES
intr_en.OVP_IEN = 1
ENABLE THERMAL
SHUTDOWN DETECTION
INTERRUPT?
YES
intr_en.TSD_IEN = 1
ENABLE
SHORT- CIRCUIT
DETECTIO N
INTERRUPT?
YES
intr_en. SHORT_IEN = 1
END
08158-018
Rev. 0 | Page 27 of 44
UG-005 Software User Guide
SERVICE_INT ERRUPTS
NOTE: THI S OPERATION GUARANTE ES THAT
ONLY THE I NTERRUPT(S) ENABLED WI LL BE
TESTED IN T HE SERVICE INTERRUPT ROUTINE
CMP_LCONTROL: VERIFIES THE
COMPARATOR 1 T RIPPING THRESHOL D
AND ADJUSTS THE BACKLI GHT BRIGHTNESS
LEVEL. THIS IMPLEMENTATION IS NOT
NEEDED IF THE AUTO CONTROL MODE
IS ENABLED. PROCESSOR CAN ALSO TEST
THE COMPARATOR 1 OUTPUTS (L2_O UT
AND L3_OUT) IN O RDER TO DETERMINE
THE CURRENT AMBIENT LIGHT LEVEL .
FORCE_RD BIT IN ccfg REGISTER
MUST BE SET TO 1 TO READ THE
COMPARATOR OUTPUTS.
CMP2_LCONTRO L: VERIFIES T HE
COMPARATOR 2 T RIPPING THRESHOL D
AND ADJUSTS THE BACKLI GHT BRIGHTNESS
LEVEL. THIS IMPLEMENTATION IS NOT
NEEDED IF THE AUTO CONTROL MODE IS
ENABLED. PROCE SSOR CAN ALSO TEST
THE COMPARATOR 2 OUTPUTS (L2_O UT2
AND L3_OUT2) IN ORDER TO DETERMINE
THE CURRENT AMBIENT LIGHT LEVEL .
FORCE_RD2 BIT IN ccfg2 REGISTER
MUST BE SET TO 1 TO READ THE
COMPARATOR OUTPUTS.
OVP_CHECK: VERIF IES THAT THE OVP
CONDITION IS REPEATED. IF NEEDED, THE
DEVICE ACTIVAT ION WILL BE ST OPPED
AND PLACED IN STANDBY MODE.
YES
WRITE BACK
mdcr2.CMP _INT = 1
(CLEAR PENDING INTERRUPT)
CMP_LCONTROL
YES
WRITE BACK
mdcr2.CMP2_I NT = 1
(CLEAR PENDING INTERRUPT)
CMP2_LCONTRO L
YES
WRITE BACK
mdcr2.OV P_INT = 1
(CLEAR PENDING INTERRUPT)
INTR_TO CHECK =
INTR_EN AND MDCR2
INTERRUPT FROM
COMPARAT OR 1
mdcr2.CMP_I NT = 1?
NO
INTERRUPT FROM
COMPARATOR 2
mdcr2.CMP2_I NT = 1?
NO
INTERRUPT F ROM
OVER-VOLTAGE DETECTION
mdcr2.OVP_INT = 1?
NO
TSD_CHECK: WHEN T HERMAL
SHUTDOWN OCCURS T HE DEVICE
WILL AUTOMATICALLY SHUTDOW N.
THE OPERATI ON AND BE PLACED IN
STANDBY MODE. THE EXTERNAL
PROCESSOR MAY MONITOR THE
TSD_INT T O BE CLEAR (DEVICE
COOLED DOW N) IN ORDER TO
RESTART THE ACTIVATION.
SHORT_CHECK: WHEN A
SHORT-CIRCUIT OCCURS THE
DEVICE WILL AUTOMATICALLY
SHUT OFF. THE EXTERNAL
PROCESSOR MAY RETRY THE
ACTIVATION A FEW TIMES BEFORE
TURNING OFF THE DEVICE AND
POSTING AN ERROR MESSAGE.
OVP_CHECK
WRITE BACK
mdcr2.TS D_INT = 1
(CLEAR PENDING INTERRUPT)
TSD_CHECK
WRITE BACK
mdcr2.OVP_INT = 1
(CLEAR PENDING INTERRUPT)
SHORT_CHECK
Figure 19. Service Interrupts Flowchart
INTERRUPT
FROM THERMAL
SHUTDOWN DETECTION
mdcr2.TSD_I NT = 1?
NO
INTERRUPT
FROM SHORT-CIRCUIT
DETECTIO N
mdcr2.OVP_INT = 1?
NO
END
08158-019
Rev. 0 | Page 28 of 44
Software User Guide UG-005
SET_LIGHT_SENSING
BACKLIGHT L EVEL CAN BE
CONTROLL ED MANUALLY BY SERVICING
COMPARATOR INTERRUPTS OR POLLI NG
THE COMPARATO R STATUS BITS IN
MDCR2 REGISTER. SEE
LIGHT_SENSING_MANUAL_CONTROL .
WRITE O FFICE TO DARK
(L3) THRESHOL D IN L3TRP
REGIS TER
WRITE DARK T O OFFICE
(L3) HYSTERESIS IN L3HYS
REGIS TER
WRITE DAYLIGHT TO
OFFICE (L2) THRESHOLD IN
L2TRP REGISTER
WRITE OFFICE TO
DAYLIGHT (L2) HYSTERESIS
IN L2HYS REGISTER
NO
NO
BACKLIGHT
AUTOLEVEL
CONTROL?
YES
SET TO 1
BITS L2_EN AND/OR L3_EN
IN CCFG REGI STER AND
BIT CMP_AUTOE N in MDCR
REGISTER
TWO
PHOTOTRANSISTORS
USED?
YES
EXAMPLE:
l3trp = 8DEC
CORRESPONDS T O 4µA OR 10 LUX
EXAMPLE:
l3hys = 10DEC
CORRESPONDS T O 5µA OR 12.5 LUX
EXAMPLE:
l2trp = 70DEC
CORRESPONDS TO 280µA OR 700 LUX
EXAMPLE:
l2hys = 80DEC
CORRESPONDS TO 320µA OR 800 LUX
ENABLING THE AUTO-LEVEL CONTROL
THE BACKLIGHT LEVEL DEPENDS ON
THE LIGHT SENSING DETECTION. UP
TWO THRESHOLD (THREE ZONES) CAN
BE DEFINED.
EXAMPLE:
ccfg.L2_E N = 1
ccfg.L3_E N = 1
mdcr.CMP_AUT OEN = 1
BOTH LEVEL S (DARK TO OFFICE AND
OFFICE TO DAYLIGHT) ARE USED TO
CONTROL AUT OMATICALLY THE BACKL IGHT.
SELECT D6 AS L ED6 SINK
IN CFGR REGISTER (CMP2_SEL)
cfgr.CPM 2_SEL = 0
cfgr.SEL_AB = 0
PHOTOTRANS ISTOR 1
cfgr.SEL_AB = 1
PHOTOTRANS ISTOR 2
SELECT D6 AS I NPUT
FOR THE SECO ND
PHOTOTRANSISTOR IN
CFGR REGISTER (CMP2_SEL)
cfgr.CPM2_ SEL = 1
YES
BACKLIGHT AUT OLEVEL
ENABLED FOR SECOND
PHOTOTRANSI STOR?
YES
SET TO 1
BITS L2_EN2 AND/OR
L3_EN2 IN CCFG 2 REGISTER
AND BIT CMP_AUTOE N IN
MDCR REGISTER
EXTERNAL PROCESSOR
SELECTS THE
PHOTOTRANSISTOR
CONTROLL ING THE BACKLIGHT.
SEL_AB BIT I N CFGR REGISTER
ALLOWS THE SELECTION
END
NO
EXAMPLE:
ccfg.L2_E N2 = 1
ccfg.L3_E N2 = 1
mdcr.CMP _AUTOEN = 1
BOTH LEVEL S (DARK TO OFFICE AND
OFFICE TO DAYLIGHT) ARE USE D TO
CONTROL AUT OMATICALLY THE BACKL IGHT.
Figure 20. Set Light Sensing Flowchart
BACKLIGHT L EVEL CAN BE
CONTROLL ED MANUALLY BY
SERVICING CO MPARATOR
INTERRUPTS OR POLLING THE
COMPARATOR ST ATUS BITS IN
MDCR2 REGISTER. SEE
LIGHT_SENSING_MANUAL_CONTROL .
08158-020
Rev. 0 | Page 29 of 44
UG-005 Software User Guide
REGISTERS MAP
Table 14.
Addr Reg. Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Refer to the ADP8860 data sheet for a detailed description of each register.
Rev. 0 | Page 30 of 44
Software User Guide UG-005
PSEUDOCODE IMPLEMENTATION
The pseudo language implementation presented in this user guide uses a C-like programming syntax to describe the registers and
functions needed to operate the backlight, individual sinks, and automatic light sensing. The goal is to provide a clear understanding for
the device functionality and this may not be the most optimized approach for the device driver development. For example, the registers
are being implemented as a C structure to better visualize and label the bit mapping of each register; however, in a real application
constants can be used since there is no need to have variables allocated for the ADP8860.
intr_en.SHORT_IEN = ENABLE_INTERRUPT; /* Enable interrupt caused by short circuits */
/* Backlight Parameters Initialization */
blsen.D5EN = LED_INDEPENDENT_SINK; /* LED 5 selected as individual sink */
blsen.D7EN = LED_INDEPENDENT_SINK; /* LED 7 selected as individual sink */
dimt = 30; /* Backlight timeout in MAX phase is 30 sec */
offt = 15; /* Backlight timeout in DIM phase is 15 sec */
blfr.BL_FI = FADING_1p5SEC; /* Backlight fade-in time is 1.5 sec */
blfr.BL_FO = FADING_4p0SEC; /* Backlight fade-out time is 4 sec */
const float BLMAX_DAYLIGHT_CURRENT_mA = 27.4; /* Default MAX daylight backlight desired current in mA */
const float BLMAX_OFFICE_CURRENT_mA = 20.7; /* Default MAX office backlight desired current in mA */
const float BLMAX_DARK_CURRENT_mA = 13.5; /* Default MAX dark backlight desired current in mA */
const float BLDIM_DAYLIGHT_CURRENT_mA = 8.5; /* Default DIM daylight backlight desired current in mA */
const float BLDIM_OFFICE_CURRENT_mA = 5; /* Default DIM office backlight desired current in mA */
const float BLDIM_DARK_CURRENT_mA = 3.5; /* Default DIM dark backlight desired current in mA */
blmx1 = CalcCurrent(BLMAX_DAYLIGHT_CURRENT_mA,cfgr.LAW,FULL_SCALE_30mA); /* Calculate the brightness
register value corresponding to the desired backlight current */