LCD PICmicro MCU Tips 'n Tricks

LCD PIC® MCU
Tips ‘n Tricks
M
Tips ‘n Tricks
Table of Contents
Tips ‘n Tricks Introduction............................... 1
TIP #1:
TIP #2:
TIP #3:
TIP #4:
TIP #5:
TIP #6:
TIP #7:
TIP #8:
TIP #9:
TIP #10:
TIP #11:
TIP #12:
Typical Ordering Considerations and
Procedures for Custom Liquid
Displays ................................................ 2
LCD PIC® MCU
Segment/Pixel Table............................. 4
Resistor Ladder for Low Current ................. 5
Contrast Control with a
Buck Regulator ................................... 11
Contrast Control Using a
Boost Regulator .................................. 13
Software Controlled Contrast with
PWM for LCD Contrast Control........... 15
Driving Common Backlights ...................... 16
In-Circuit Debug (ICD)............................... 19
LCD in Sleep Mode ................................... 20
How to Update LCD Data
Through Firmware............................... 22
Blinking LCD.............................................. 23
4 x 4 Keypad Interface that
Conserves Pins for LCD Segment
Drivers................................................. 25
Reference Documentation ............................. 29
Worldwide Sales and Service ........................ 34
© 2007 Microchip Technology Inc.
DS41261B-page i
Tips ‘n Tricks
NOTES:
DS41261B-page ii
© 2007 Microchip Technology Inc.
Tips ‘n Tricks
TIPS ‘N TRICKS INTRODUCTION
Using an LCD PIC® MCU for any embedded
application can provide the benefits of system
control and human interface via an LCD. Design
practices for LCD applications can be further
enhanced through the implementation of these
suggested “Tips ‘n Tricks”.
This booklet describes many basic circuits and
software building blocks commonly used for
driving LCD displays. The booklet also provides
references to Microchip application notes that
describe many LCD concepts in more detail.
© 2007 Microchip Technology Inc.
DS41261B-page 1
Tips ‘n Tricks
TIP #1
Typical Ordering Considerations
and Procedures for Custom
Liquid Displays
1. Consider what useful information needs to
be displayed on the custom LCD and the
combination of alphanumeric and custom
icons that will be necessary.
2. Understand the environment in which the LCD
will be required to operate. Operating voltage
and temperature can heavily influence the
contrast of the LCD and potentially limit the
type of LCD that can be used.
3. Determine the number of segments necessary
to achieve the desired display on the LCD and
reference the PIC® Microcontroller LCD matrix
for the appropriate LCD PIC Microcontroller.
4. Create a sketch/mechanical print and written
description of the custom LCD and understand
the pinout of the LCD. (Pinout definition is best
left to the glass manufacturer due to the
constraints of routing the common and
segment electrodes in two dimensions.)
DS41261B-page 2
© 2007 Microchip Technology Inc.
Tips ‘n Tricks
5. Send the proposed LCD sketch and
description for a written quotation to at least
3 vendors to determine pricing, scheduling and
quality concerns.
5.1 Take into account total NRE cost, price per
unit, as well as any setup fees.
5.2 Allow a minimum of two weeks for formal
mechanical drawings and pin
assignments and revised counter
drawings.
6. Request a minimal initial prototype LCD build
to ensure proper LCD development and
ensure proper functionality within the target
application.
6.1 Allow typically 4-6 weeks for initial LCD
prototype delivery upon final approval of
mechanical drawings and pin
assignments.
7. Upon receipt of prototype LCD, confirm
functionality before giving final approval and
beginning production of LCD.
Note: Be sure to maintain good records by
keeping copies of all materials
transferred between both parties, such
as initial sketches, drawings, pinouts, etc.
© 2007 Microchip Technology Inc.
DS41261B-page 3
Tips ‘n Tricks
LCD PIC® MCU
Segment/Pixel Table
TIP #2
TABLE 2-1:
SEGMENT MATRIX TABLE
Maximum Number of Segments/Pixels
Multiplex
Bias
Commons PIC16F913/ PIC16F914/
PIC18F6X90
PIC18F8X90
PIC16F946
916
917
(PIC18F6XJ90) (PIC18F8XJ90)
Static
(COM0)
15
24
42
32/
(33)
48
Static
1/2 (COM1:
COM0)
30
48
84
64/
(66)
96
1/2 or
1/3
1/3 (COM2:
COM0)
45
72
126
96/
(99)
144
1/2 or
1/3
1/4 (COM3:
COM0)
60
96
168
128/
(132)
192
1/3
This Segment Matrix table shows that Microchip’s
80-pin LCD devices can drive up to 4 commons
and 48 segments (192 pixels), 64-pin devices can
drive up to 33 segments (132 pixels), 40/44 pin
devices can drive up to 24 segments (96 pixels)
and 28-pin devices can drive 15 segments
(60 segments).
DS41261B-page 4
© 2007 Microchip Technology Inc.
Tips ‘n Tricks
TIP #3
Resistor Ladder for Low Current
Bias voltages are generated by using an external
resistor ladder. Since the resistor ladder is
connected between VDD and VSS, there will be
current flow through the resistor ladder in inverse
proportion to the resistance. In other words, the
higher the resistance, the less current will flow
through the resistor ladder. If we use 10K resistors
and VDD = 5V, the resistor ladder will continuously
draw 166 μA. That is a lot of current for some
battery-powered applications.
FIGURE 3-1:
VDD
RESISTOR LADDER
LCD PIC® MCU
VLCD3
R
SEGn
VLCD2
CPIXEL (n x m)
R
VLCD1
COMm
R
VLCD0
VSS
How do we maximize the resistance without
adversely effecting the quality of the display?
Some basic circuit analysis helps us determine
how much we can increase the size of the resistors
in the ladder.
© 2007 Microchip Technology Inc.
DS41261B-page 5
Tips ‘n Tricks
The LCD module is basically an analog multiplexer
that alternately connects the LCD voltages to the
various segment and common pins that connect
across the LCD pixels. The LCD pixels can be
modeled as a capacitor. Each tap point on the
resistor ladder can be modeled as a Thevenin
equivalent circuit. The Thevenin resistance is 0 for
VLCD3 and VLCD0, so we look at the two cases
where it is non-zero, VLCD2 and VLCD1.
The circuit can be simplified as shown in Figure 3-2.
RSW is the resistance of the segment multiplex
switch; RCOM is the resistance of the common
multiplex switch.
FIGURE 3-2:
SIMPLIFIED LCD CIRCUIT
RTH
VTH
+
–
RSW
CPIXEL
RCOM
The Thevenin voltage is equal to either 2/3 VDD, or
1/3 VDD, for the cases where the Thevenin
resistance is non-zero. The Thevenin resistance is
equal to the parallel resistance of the upper and
lower parts of the resistor ladder.
DS41261B-page 6
© 2007 Microchip Technology Inc.
Tips ‘n Tricks
FIGURE 3-3:
LCD CIRCUIT RESISTANCE ESTIMATE
RTH = (2R * R)/(2R + R)
RTH = 2R2/3R
RTH = 2R/3
RSW = 4.7K
RCOM = 0.4K
RTOTAL = RTH + RSW + RCOM
VTH +
–
CPIXEL
As you can see, we can model the drive of a single
pixel as an RC circuit, where the voltage switches
from 0V to VLCD2, for example. For LCD PIC®
microcontrollers, we can estimate the resistance of
the segment and common switching circuits as
about 4.7K and 0.4K, respectively.
We can see that the time for the voltage across the
pixel to change from 0 to VTH will depend on the
capacitance of the pixel and the total resistance, of
which the resistor ladder Thevenin resistance
forms the most significant part.
FIGURE 3-4:
VOLTAGE CHANGE ACROSS PIXEL
RTOTAL
VPIXEL
VTH
+
–
© 2007 Microchip Technology Inc.
CPIXEL
DS41261B-page 7
Tips ‘n Tricks
The step response of the voltage across a pixel is
subject to the following equation:
EQUATION 3-1:
VPIXEL = VTH (1 – e-t/RC)
By manipulating the equation, we can see that it
will take a time equal to 4 time constants for the
pixel voltage to reach 98% of the bias voltage.
FIGURE 3-5:
STEP RESPONSE DIAGRAM
VPIXEL
VPIXEL/VTH = 1 – e-t/RC
98% = 1 – e-t/RC
VTH
2% = e-t/RC
0.98 VTH
In (.02) = -t/RC
t = ~ 4 RC
0
t = 4 RC
t
Now we need to estimate the capacitance.
Capacitance is proportional to the area of a pixel.
We can measure the area of a pixel and estimate
the capacitance as shown. Obviously, a bigger
display, such as a digital wall clock, will have
bigger pixels and higher capacitance.
EQUATION 3-2:
CPIXEL = 1500 pF/cm2
AREAPIXEL = 1 mm * 3 mm = .03 cm2
CPIXEL = 45 pF
DS41261B-page 8
© 2007 Microchip Technology Inc.
Tips ‘n Tricks
We want the time constant to be much smaller
than the period of the LCD waveform, so that
rounding of the LCD waveform will be minimized.
If we want the RC to be equal to 100 μS, then the
total resistance can be calculated as shown:
EQUATION 3-3:
RTOTAL = 100 μS/45 pF = 2.22 mOhms
RTH = 2.2M – 5.1K = 2.2M
The resistance of the switching circuits within the
LCD module is very small compared to this
resistance, so the Thevenin resistance of the
resistor ladder at VLCD2 and VLCD1 can be treated
the same as RTOTAL. We can then calculate the
value for R that will give us the correct Thevenin
resistance.
EQUATION 3-4:
R = 3 RTH/2 = 3.3M
Now we can calculate the current through the
resistor ladder if we used 3.3 mOhm resistors.
EQUATION 3-5:
RLADDER = 9.9M,
ILADDER = 5V/9.9M = 0.5 μA
© 2007 Microchip Technology Inc.
DS41261B-page 9
Tips ‘n Tricks
Use this process to estimate maximum resistor
sizes for your resistor ladder and you will
drastically reduce power consumption for your
LCD application. Don’t forget to observe the
display over the operating conditions of your
product (such as temperature, voltage and even,
humidity) to ensure that contrast and display
quality is good.
DS41261B-page 10
© 2007 Microchip Technology Inc.
Tips ‘n Tricks
TIP #4
Contrast Control with a Buck
Regulator
Contrast control in any of the LCD PIC MCUs is
accomplished by controlling the voltages applied
to the VLCD voltage inputs. The simplest contrast
voltage generator is to place a resistor divider
across the three pins. This circuit is shown in the
data sheet. The resistor ladder method is good for
many applications, but the resistor ladder does not
work in an application where the contrast must
remain constant over a range of VDDs. The
solution is to use a voltage regulator. The voltage
regulator can be external to the device, or it can be
built using a comparator internal to the LCD PIC
microcontroller.
FIGURE 4-1:
VOLTAGE GENERATOR WITH RESISTOR
DIVIDER
VDD
RA1
RA5
R6
VLCD3
C1
R1
VLCD2
C2
R4
0.6V
LCD
Glass
R2
VLCD1
C3
R5
R3
PIC16F91X
© 2007 Microchip Technology Inc.
DS41261B-page 11
Tips ‘n Tricks
The PIC16F946/917/916/914/913 devices have a
special Comparator mode that provides a fixed
0.6V reference. The circuit shown in Figure 4-1
makes use of this reference to provide a regulated
contrast voltage. In this circuit, R1, R2 and R3
provide the contrast control voltages. The voltage
on VLCD3 is compared to the internal voltage
reference by dividing the voltage at VLCD3 at R4
and R5 and applying the reduced voltage to the
internal comparator. When the voltage at VLCD3 is
close to the desired voltage, the output of the
comparator will begin to oscillate. The oscillations
are filtered into a DC voltage by R6 and C1. C2
and C3 are simply small bypass capacitors to
ensure that the voltages at VLCD1 and VLCD2 are
steady.
DS41261B-page 12
© 2007 Microchip Technology Inc.
Tips ‘n Tricks
TIP #5
Contrast Control Using a Boost
Regulator
In LCD Tip #4, a buck converter was created using
a comparator. This circuit works great when VDD is
greater than the LCD voltage. The PIC
microcontroller can operate all the way down to
2.0V, whereas most low-voltage LCD glass only
operates down to 3V. In a battery application, it is
important to stay operational as long as possible.
Therefore, a boost converter is required to boost
2.0V up to 3.0V for the LCD.
The figure below shows one circuit for doing this.
FIGURE 5-1:
BOOST CONVERTER
R1
R2
D1
D2
R4
R3
Boost
Q1
C1
C1
R5
VDD
C2
R6
C2
D3
R7
PIC16F946/917/916/914/913
© 2007 Microchip Technology Inc.
DS41261B-page 13
Tips ‘n Tricks
In this circuit, both comparators are used. The
voltage setpoint is determined by the value of
Zenier diode D3 and the voltage at R6:R7. The rest
of the circuit creates a simple multivibrator to
stimulate a boost circuit. The boost circuit can be
inductor or capacitor-based. When the output
voltage is too low, the multivibrator oscillates and
causes charge to build up in C2. As the voltage at
C2 increases, the multivibrator will begin to operate
sporadically to maintain the desired voltage at C2.
FIGURE 5-2:
TWO TYPES OF BOOST CONVERTER
VBAT
VBAT
L1
R8
Q2
The two methods of producing a boost converter
are shown above. The first circuit is simply a
switched capacitor type circuit. The second circuit
is a standard inductor boost circuit. These circuits
work by raising VDD. This allows the voltage at
VLCD to exceed VDD.
DS41261B-page 14
© 2007 Microchip Technology Inc.
Tips ‘n Tricks
TIP #6
Software Controlled Contrast with
PWM for LCD Contrast Control
In the previous contrast control circuits, the voltage
output was set by a fixed reference. In some
cases, the contrast must be variable to account for
different operating conditions. The CCP module,
available in the LCD controller devices, allows a
PWM signal to be used for contrast control. In
Figure 6-1, you see the buck contrast circuit
modified by connecting the input to RA6 to a CCP
pin. The resistor divider created by R4 and R5 in
the previous design are no longer required. An
input to the ADC is used to provide feedback but
this can be considered optional. If the ADC
feedback is used, notice that it is used to monitor
the VDD supply. The PWM will then be used to
compensate for variations in the supply voltage.
FIGURE 6-1:
SOFTWARE CONTROLLED VOLTAGE
GENERATOR
VDD
VDD
AN0
R6
R5
CCP
VLCD3
R1
C1
VLCD2
C2
LCD
Glass
R2
D1
VLCD1
C3
R3
LCD PIC®
MCU
© 2007 Microchip Technology Inc.
DS41261B-page 15
Tips ‘n Tricks
TIP #7
Driving Common Backlights
Any application that operates in a low light
condition requires a backlight. Most low-cost
applications use one of the following backlights:
1) Electroluminescent (EL),
2) LEDs in series, or
3) LEDs in parallel.
Other backlight technologies, such as CCFL, are
more commonly used in high brightness graphical
panels, such as those found in laptop computers.
The use of white LEDs is also more common in
color LCDs, where a white light source is required
to generate the colors.
Driving an EL panel simply requires an AC signal.
You may be able to generate this signal simply by
using an unused segment on the LCD controller.
The signal can also be generated by a CCP
module or through software. The AC signal will
need to pass through a transformer for voltage
gain to generate the required voltage across the
panel.
DS41261B-page 16
© 2007 Microchip Technology Inc.
Tips ‘n Tricks
LEDs in series can be easily driven with a boost
power supply. In the following diagram, a simple
boost supply is shown. In this circuit, a pulse is
applied to the transistor. The pulse duration is
controlled by current through R2. When the pulse
is turned off, the current stored in the inductor will
be transferred to the LEDs. The voltage will rise to
the level required to drive the current through the
LEDs. The breakdown voltage of the transistor
must be equal to the forward voltage of the LEDs
multiplied by the number of LEDs. The comparator
voltage reference can be adjusted in software to
change the output level of the LEDs.
FIGURE 7-1:
SIMPLE BOOST SUPPLY
VDD
L1
R1
Q2
LED String
To Comparator Input
R2
© 2007 Microchip Technology Inc.
DS41261B-page 17
Tips ‘n Tricks
If the LEDs are in parallel, the drive is much
simpler. In this case, a single transistor can be
used to sink the current of many LEDs in parallel.
The transistor can be modulated by PWM to
achieve the desired output level. If VDD is higher
than the maximum forward voltage, a resistor can
be added to control the current, or the transistor
PWM duty cycle can be adjusted to assure the
LEDs are operating within their specification.
FIGURE 7-2:
LEDS IN PARALLEL
VDD
LED
String
R1
DS41261B-page 18
© 2007 Microchip Technology Inc.
Tips ‘n Tricks
TIP #8
In-Circuit Debug (ICD)
There are two potential issues with using the ICD
to debug LCD applications. First, the LCD
controller can Freeze while the device is Halted.
Second, the ICD pins are shared with segments on
the PIC16F946/917/916/914/913 MCUs.
When debugging, the device is Halted at
breakpoints and by the user pressing the pause
button. If the ICD is configured to Halt the
peripherals with the device, the LCD controller will
Halt and apply DC voltages to the LCD glass. Over
time, these DC levels can cause damage to the
glass; however, for most debugging situations, this
will not be a consideration. The PIC18F LCD
MCUs have a feature that allows the LCD module
to continue operating while the device has been
Halted during debugging. This is useful for
checking the image of the display while the device
is Halted and for preventing glass damage if the
device will be Halted for a long period of time.
The PIC16F946/917/916/914/913 multiplex the
ICSP™ and ICD pins onto pins shared with LCD
segments 6 and 7. If an LCD is attached to these
pins, the device can be debugged with ICD;
however, all the segments driven by those two pins
will flicker and be uncontrolled. As soon as
debugging is finished and the device is
programmed with Debug mode disabled, these
segments will be controlled correctly.
© 2007 Microchip Technology Inc.
DS41261B-page 19
Tips ‘n Tricks
TIP #9
LCD in Sleep Mode
If you have a power-sensitive application that must
display data continuously, the LCD PIC
microcontroller can be put to Sleep while the LCD
driver module continues to drive the display.
To operate the LCD in Sleep, only two steps are
required. First, a time source other than the main
oscillator must be selected as the LCD clock
source, because during Sleep, the main oscillator
is Halted. Options are shown for the various LCD
PIC MCUs.
TABLE 9-1:
OPTIONS FOR LCD IN SLEEP MODE
Part
PIC16C925/926
PIC16F946/917/
916/914/913
PIC18F6X90
PIC18F8X90
PIC18F6XJ90
PIC18F8XJ90
LCD Clock Source
Use in
Sleep?
FOSC/256
No
T1OSC
Yes
Internal RC Oscillator
Yes
FOSC/8192
No
T1OSC/32
Yes
LFINTOSC/32
Yes
(FOSC/4)/8192
No
T1OSC
Yes
INTRC/32
Yes
Second, the Sleep Enable bit (SLPEN) must be
cleared. The LCD will then continue to display data
while the part is in Sleep. It’s that easy!
DS41261B-page 20
© 2007 Microchip Technology Inc.
Tips ‘n Tricks
When should you select the internal RC oscillator
(or LFINTOSC) over the Timer1 oscillator? It
depends on whether your application is
time-sensitive enough to require the accuracy of a
crystal on the Timer1 oscillator or not. If you have
a timekeeping application, then you will probably
have a 32 kHz crystal oscillator connected to
Timer1.
Since Timer1 continues to operate during Sleep,
there is no penalty in using Timer1 as the LCD
clock source. If you don’t need to use an external
oscillator on Timer1, then the internal RC oscillator
(INTRC or LFINTOSC) is more than sufficient to
use as the clock source for the LCD and it requires
no external components.
© 2007 Microchip Technology Inc.
DS41261B-page 21
Tips ‘n Tricks
TIP #10 How to Update LCD Data
Through Firmware
To update the LCD, the content of the LCDDATA
registers is modified to turn on, or off, each pixel on
the LCD display. The application firmware will
usually modify buffer variables that are created to
correspond with elements on the display, such as
character positions, bar graph, battery display, etc.
When the application calls for a display update, the
values stored in the buffer variables must be
converted to the correct setting of the pixel bits,
located in the LCDDATA registers.
For Type-A waveforms, the LCD Data registers
may be written any time without ill effect. However,
for Type-B waveforms, the LCD Data registers can
only be written every other LCD frame in order to
ensure that the two frames of the Type-B
waveform are compliments of one another.
Otherwise, a DC bias can be presented to the
LCD.
The LCD Data registers should only be written
when a write is allowed, which is indicated by the
WA bit in the LCDCON register being set.
On the PIC16C926 parts, there is no WA bit. The
writing of the pixel data can be coordinated on an
LCD interrupt. The LCD interrupt is only generated
when a multiplexed (not static) Type-B waveform
is selected.
DS41261B-page 22
© 2007 Microchip Technology Inc.
Tips ‘n Tricks
TIP #11 Blinking LCD
Information can be displayed in more than one
way with an LCD panel. For example, how can the
user’s attention be drawn to a particular portion of
the LCD panel? One way that does not require any
additional segments is to create a blinking effect.
Look at a common clock application. The “:”
between the hours and minutes is commonly
made to blink once a second (on for half a second,
off for half a second). This shows that the clock is
counting in absence of the ticking sound or second
hand that accompanies the usual analog face
clock. It serves an important purpose of letting the
user know that the clock is operating.
If there is a power outage, then it is common for the
entire clock display to blink. This gives the user of
the clock an immediate indication that the clock is
no longer showing the correct time.
When the user sets the time, then blinking is
commonly used to show that a new mode has
been entered, such as blinking the hours to identify
that the hours are being set, or blinking the
minutes to show that the minutes are being set. In
a simple clock, blinking is used for several different
purposes. Without blinking effects, the common
digital clock would not be nearly as user friendly.
© 2007 Microchip Technology Inc.
DS41261B-page 23
Tips ‘n Tricks
FIGURE 11-1:
COMMON CLOCK APPLICATION
Fortunately, blinking is quite easy to implement.
There are many ways to implement a blinking
effect in software. Any regular event can be used
to update a blink period counter. A blink flag can be
toggled each time the blink period elapses. Each
character or display element that you want to blink
can be assigned a corresponding blink enable flag.
The flowchart for updating the display would look
like:
FIGURE 11-2:
UPDATING DISPLAY FLOWCHART
Update Character 1
Start
Blink Flag
Character 1
Blink
Enable
Character 1
Buffer
Is Blink
flag
set?
Y
Is
Character 1
blink enable
set?
N
N
Y
Clear
Character 1
Pixels
LCDDATA
Pixel Bits
Update
Character 1
Pixels
Finish
DS41261B-page 24
© 2007 Microchip Technology Inc.
Tips ‘n Tricks
TIP #12 4 x 4 Keypad Interface that
Conserves Pins for LCD
Segment Drivers
A typical digital interface to a 4 x 4 keypad uses
8 digital I/O pins. But using eight pins as digital
I/Os can take away from the number of segment
driver pins available to interface to an LCD.
By using 2 digital I/O pins and 2 analog input pins,
it is possible to add a 4 x 4 keypad to the
PIC microcontroller without sacrificing any of its
LCD segment driver pins.
The schematic for keypad hook-up is shown in
Figure 12-1. This example uses the PIC18F8490,
but the technique could be used on any of the LCD
PIC MCUs.
© 2007 Microchip Technology Inc.
DS41261B-page 25
Tips ‘n Tricks
FIGURE 12-1:
KEYPAD HOOK-UP SCHEMATIC
The two digital I/O pins that are used are RB0 and
RB5, but any two digital I/O pins could work. The
two analog pins used are AN0 and AN1.
DS41261B-page 26
© 2007 Microchip Technology Inc.
Tips ‘n Tricks
To read the keypad, follow the steps below:
1. First, make RB0 an output high and RB5 an
input (to present a high impedance).
2. Perform two successive A/D conversions, first
on AN0, then on AN1.
3. Save the conversion results to their respective
variables; for example, RB0_AN0_Result and
RB0_AN1_Result.
4. Next, make RB5 an output high and RB0 an
input (to present a high impedance).
5. Perform two successive A/D conversions, first
on AN0, then on AN1.
6. Save the conversion results to their respective
variables; for example, RB5_AN0_Result and
RB5_AN1_Result.
7. There are now 4 variables that represent a key
press in each quadrant of the 4 x 4 keypad:
- RB0_AN0_Result – denotes key press
of 1, 2, 4 or 5.
- RB0_AN1_Result – denotes key press
of 7, 8, A or 0.
- RB5_AN0_Result – denotes key press
of 3, C, 6 or D.
- RB5_AN1_Result – denotes key press
of 9, E, B or F.
8. Finally, check each value against the matching
column of Table 12-1. If it is within +/-10% of a
value, then it can be taken to indicate that the
corresponding key has been pressed.
© 2007 Microchip Technology Inc.
DS41261B-page 27
Tips ‘n Tricks
TABLE 12-1:
Value
+/-10%
KEYPAD VALUES
RB0_AN0
RB0_AN1
RB5_AN0
RB5_AN1
<VDD/10
—
—
—
—
VDD/5.2
2
8
C
E
VDD/4.2
1
7
3
9
VDD/3
5
0
D
F
VDD/2
4
A
6
B
9. This loop should be repeated about once every
20 ms or so.
Don’t forget a debounce routine. For example,
require the above steps (with 20 ms delay
between) to return the same key value twice in a
row for that key to be considered pressed. Also,
require a no key press to be returned at least twice
before looking for the next key press.
When keys within the same quadrant are pressed
simultaneously, voltages other than the four valid
levels shown in the table may be generated. These
levels can either be ignored, or if you want to use
simultaneous key presses to enable certain
functions, you can add decoding for those levels
as well.
DS41261B-page 28
© 2007 Microchip Technology Inc.
Tips ‘n Tricks
REFERENCE DOCUMENTATION
AN220, “Watt-Hour Meter Using PIC16C923
and CS5460” (DS00220)
AN582, “Low-Power Real-Time Clock” (DS00582)
AN587, Interfacing PIC® MCUs to an
LCD Module” (DS00587)
AN649, “Yet Another Clock Featuring the
PIC16C924” (DS00649)
AN658, “LCD Fundamentals Using PIC16C92X
Microcontrollers” (DS00658)
TB084, “Contrast Control Circuits for the
PIC16F91X” (DS91084)
© 2007 Microchip Technology Inc.
DS41261B-page 29
Tips ‘n Tricks
NOTES:
DS41261B-page 30
© 2007 Microchip Technology Inc.
Tips ‘n Tricks
NOTES:
© 2007 Microchip Technology Inc.
DS41261B-page 31
Tips ‘n Tricks
NOTES:
DS41261B-page 32
© 2007 Microchip Technology Inc.
Information contained in this publication regarding device applications and the like is provided only for your convenience and may
be superseded by updates. It is your responsibility to ensure that
your application meets with your specifications. MICROCHIP
MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY
KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL,
STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION,
QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS
FOR PURPOSE. Microchip disclaims all liability arising from this
information and its use. Use of Microchip devices in life support and/
or safety applications is entirely at the buyer’s risk, and the buyer
agrees to defend, indemnify and hold harmless Microchip from any
and all damages, claims, suits, or expenses resulting from such use.
No licenses are conveyed, implicitly or otherwise, under any
Microchip intellectual property rights.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron,
dsPIC, KEELOQ, KEELOQ logo, microID, MPLAB, PIC, PICmicro,
PICSTART, PRO MATE, rfPIC, and SmartShunt are registered
trademarks of Microchip Technology Incorporated in the U.S.A.
and other countries.
AmpLab, FilterLab, Linear Active Thermistor, Migratable
Memory, MXDEV, MXLAB, SEEVAL, SmartSensor and The
Embedded Control Solutions Company are registered
trademarks of Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, CodeGuard,
dsPICDEM, dsPICDEM.net, dsPICworks, ECAN,
ECONOMONITOR, FanSense, FlexROM, fuzzyLAB, In-Circuit
Serial Programming, ICSP, ICEPIC, Mindi, MiWi, MPASM,
MPLAB Certified logo, MPLIB, MPLINK, PICkit, PICDEM,
PICDEM.net, PICLAB, PICtail, PowerCal, PowerInfo,
PowerMate, PowerTool, REAL ICE, rfLAB, Select Mode, Smart
Serial, SmartTel, Total Endurance, UNI/O, WiperLock and ZENA
are trademarks of Microchip Technology Incorporated in the
U.S.A. and other countries.
SQTP is a service mark of Microchip Technology Incorporated in
the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
© 2007, Microchip Technology Incorporated, Printed in the
U.S.A., All Rights Reserved.
Printed on recycled paper.
© 2007 Microchip Technology Inc.
DS41261B-page 33
M
Worldwide Sales and Service
AMERICAS
China-Hong Kong
Philippines-Manila
SAR
Tel: 63-2-634-9065
Tel: 852-2401-1200
Singapore
China-Qingdao
Tel: 65-6334-8870
Tel: 86-532-8502-7355 Taiwan-Hsin Chu
Tel: 886-3-572-9526
China-Shanghai
Taiwan-Kaohsiung
Tel: 86-21-5407-5533
Tel: 886-7-536-4818
China-Shenyang
Taiwan-Taipei
Tel: 86-24-2334-2829
Tel: 886-2-2500-6610
China-Shenzhen
Thailand-Bangkok
Tel: 86-755-8203-2660 Tel: 66-2-694-1351
China-Shunde
EUROPE
Tel: 86-757-2839-5507 Austria-Weis
China-Wuhan
Tel: 43-7242-2244-39
Tel: 86-27-5980-5300
Denmark-Copenhagen
Tel: 45-4450-2828
China-Xian
Tel: 86-29-8833-7250
France-Paris
India-Bangalore
Tel: 33-1-69-53-63-20
Tel: 91-80-4182-8400
Germany-Munich
India-New Delhi
Tel: 49-89-627-144-0
Tel: 91-11-4160-8631
Italy-Milan
India-Pune
Tel: 39-0331-742611
Tel: 91-20-2566-1512
ASIA/PACIFIC
Netherlands-Drunen
Australia
Tel: 31-416-690399
Japan-Yokohama
Tel: 61-2-9868-6733
Tel: 81-45-471- 6166
Spain-Madrid
China-Beijing
Tel: 34-91-708-08-90
Korea-Gumi
Tel: 86-10-8528-2100
Tel: 82-54-473-4301
UK-Wokingham
China-Chengdu
Tel: 44-118-921-5869
Korea-Seoul
Tel: 86-28-8665-5511
Tel: 82-2-554-7200
12/08/06
China-Fuzhou
Malaysia-Penang
Tel: 86-591-8750-3506 Tel: 60-4-646-8870
Microchip received ISO/TS-16949:2002
certification for its worldwide headquarters, design
and wafer fabrication facilities in Chandler and
Tempe, Arizona; Gresham, Oregon and design
centers in California and India. The Company’s
quality system processes and procedures are for its
PIC® MCUs and dsPIC® DSCs, KEELOQ® code
hopping devices, Serial EEPROMs,
microperipherals, nonvolatile memory and analog
products. In addition, Microchip’s quality system for
the design and manufacture of development
systems is ISO 9001:2000 certified.
Corporate Office
Tel: 480-792-7200
Technical Support:
http://support.microchip.com
Atlanta
Tel: 678-957-9614
Boston
Tel: 774-760-0087
Chicago
Tel: 630-285-0071
Dallas
Tel: 972-818-7423
Detroit
Tel: 248-538-2250
Kokomo
Tel: 765-864-8360
Los Angeles
Tel: 949-462-9523
Santa Clara
Tel: 408-961-6444
Toronto
Tel: 905-673-0699
*DS41261B*
DS41261B-page 34
© 2007 Microchip Technology Inc.
Microchip Technology Inc.
2355 W. Chandler Blvd. • Chandler, AZ 85224 U.S.A.
Phone: 480-792-7200 • Fax: 480-792-9210
www.microchip.com
© 2007, Microchip Technology Inc., 4/07 DS41261B
*DS41261B*