Interfacing to LCDs, LEDs and Input Keys with Pin

Interfacing to LCDs, LEDs and Input Keys with Pin
Interfacing to LCDs, LEDs and Input Keys with Pin-shared I/Os in the HT66Fx0
Interfacing to LCDs, LEDs and Input Keys
with Pin-shared I/Os in the HT66Fx0
D/N:HA0196E
Introduction
The HT66Fx0 contains an internal R-Type LCD driving function with a 1/2 bias and four
COM driving capability. The following provides a description of how to drive LCDs, LEDs
and input keys using pin-shared I/Os.
Operating Principles
Microelectronic components often use time division methods for driving. This method can
be used to implement a way of driving LCDs, LEDs and also scan input switches which
share the same common pins.
From the basic 1/2 bias 1/4 duty COM driving waveform, we can see the following time
division order diagram:
LCD driving is implemented during the T0~T7 time intervals, switch scanning is
implemented during T8, and LED driving is implemented during T9.
1
Interfacing to LCDs, LEDs and Input Keys with Pin-shared I/Os in the HT66Fx0
According to LCD driving principles, LCD pixels can only be used with AC voltages. The
LCD display contras is determined by the voltage value on the COM pin minus that on the
SEG pin. This value is also determined by the LCD pixels on/off control. The LCD type
MCU automatically generates the LCD driving signals using its internal LCD driving circuit,
as long as the I/O port can simulate the LCD driving output signals.
For best operation the LCD frame frequency should be within a range of 25Hz ~ 250Hz.
When the HT66F40 system clock uses the HIRC 4MHz oscillator, and the time base input
frequency is equal to fSYS/4, the overflow time setting of the Time Base will be 2.048ms.
Taking this as the time base, the 1/4 duty frame period is:
2.048 ms * 10 = 20.48 ms, that is 1000/ 20.48 =48.12Hz.
This matches the requirements.
Setting the time base to have different overflow times according to actual application
requirements is of course allowable. However it must be noted that the system frequency
should not be FL or else the scan time will not be long enough for a good visual effect; this
is because the system frequency is too slow and will result in LCD blinking effects. In
addition, when the time base is set to have other overflow times, the higher scanning
frequency will enhance the brightness of the LED.
The HT66F40 contains 4 COM outputs that allow the PC0, PC1, PC6 and PC7 pins to
output a VDD/2 voltage using the SCOMC register and without needing external bias
resistors. The internal circuit and setup is shown as follows.
V
D D
V
S C O M
D D
o p e r a tin g c u r r e n t
/2
S C O M 0 ~
S C O M 3
C O M n E N
S C O M E N
SCOM Circuit
Output Control
2
Interfacing to LCDs, LEDs and Input Keys with Pin-shared I/Os in the HT66Fx0
Different LCD panels may require different driving currents. For driving different LCD
panels, the device also includes four driving current options which users can select to
change the LCD driving current. This is implemented using the ISEL1 and ISEL0 bits in
the SCOMC register as shown below.
ISEL1, ISEL0
00: 25uA
01: 50uA
10: 100uA
11: 200uA
Note that the above current are setup when VDD=5V. For more details refer to the
datasheet.
Setting the corresponding voltage on the COM0~COM3 outputs at 2.048ms intervals
within one COM cycle can generate the COM0~COM3 waveform. To be more specific,
set the COM0 output to a VDD output level at the first time base overflow and set the
other COM outputs to a VDD/2 output level. Set COM0 to a VSS output level at the
second time base overflow and the other COM1~COM3 outputs to a VDD/2 output level.
Set the COM1 output to a VDD output level at the third time base overflow and the other
COM outputs to a VDD/2 output level. Set the COM1 output to a VSS output level at the
fourth time base overflow and the other COM outputs to a VDD/2 output level … etc. Set
the COM3 output to a VSS output level at the eighth time base overflow and other COM
outputs to a VDD/2 output level. Set the key scanning time to be at the ninth interrupt and
the LED output time to be at the tenth interrupt.
To illuminate the LCD, the differential voltage between COM and SEG should be greater
than the saturation voltage, that is, +VDD or -VDD. Therefore to illuminate a pixel one
only needs to output a complimentary voltage on the corresponding SEG output and its
corresponding COM output. For example, when COM0=VDD, the corresponding pixel will
be illuminated if SEG=VSS. When COM0=VSS, the corresponding pixel will be
illuminated if SEG=VDD.
From the application note HA0168E, there is another method to execute the LCD driving
more directly using the following time division steps.
(1) Set COM0 to output high at the first overflow and the other COMs to output VDD/2
and then set each SEG output according to the data to be displayed.
(2) Set COM1 to output high at the second overflow and the other COMs to output VDD/2
and then set each SEG output according to the data to be displayed.
(3) Set COM2 and COM3 to output high at the third overflow and fourth interrupt as
shown above and according to the data to be displayed.
3
Interfacing to LCDs, LEDs and Input Keys with Pin-shared I/Os in the HT66Fx0
(4) Set COM0 to output low at the fifth overflow and the other COMs to output VDD/2
and then set each SEG output according to the data to be displayed.
(5) Set COM1, COM2 and COM3 at the sixth, seventh and eighth overflow to output low
according to step 4 and the data to be displayed.
(6) Execute switch scanning at the ninth overflow.
(7) Illuminate the LEDs at the tenth overflow.
The timing diagram for this method is shown below.
Users may modify the demo code attached in the application note HA0168E according to
the above timing.
4
Interfacing to LCDs, LEDs and Input Keys with Pin-shared I/Os in the HT66Fx0
Application Circuit
Circuit Description
The LED illumination can be controlled by decreasing the current limiting resistor or
increasing the scanning frequency using the application program. However the current
limiting resistor should not be less than 120 or else the sensitivity of the input switch will
be affected. It is recommended to control LED illumination by increasing the scanning
frequency using the application program.
In order to decrease the effect on the LCD display by simultaneous multiple key
operations, the switch resistors should be larger than 2.2k but less than 4k, or the
sensitivity will be reduced.
5
Interfacing to LCDs, LEDs and Input Keys with Pin-shared I/Os in the HT66Fx0
S/W Flowchart
Program Description
The example program uses a 4x8 segment LCD, to cycle a number from 000 to 999 on
the display at an interval of 0.512 seconds. When a key is pressed, the rightmost LCD
character will display the key number. In the program, display_num0, display_num1,
display_num2 are used to store the numbers to be displayed, while display_num3 store
the key number being pressed. Users may decide which COM and SEGs are to be used
according to specific demands. If the LCD is 1/3 duty, for example if only three COMs are
required, then the SEGs may be expanded according to the example program.
From the description above, set the COM0~COM3 outputs respectively to have 8
intervals. Whether the SEG outputs are VDD or VSS depends upon the number to be
displayed. When using the first driving method, the I/O port voltage levels are provided in
the accompanying table.
First Interrupt
Second Interrupt
Third Interrupt
Fourth Interrupt
Fifth Interrupt
Sixth Interrupt
Seventh Interrupt
Eighth Interrupt
COM0
COM1
COM2
COM3
VDD
VSS
VDD/2
VDD/2
VDD/2
VDD/2
VDD/2
VDD/2
VDD/2
VDD/2
VDD
VSS
VDD/2
VDD/2
VDD/2
VDD/2
VDD/2
VDD/2
VDD/2
VDD/2
VDD
VSS
VDD/2
VDD/2
VDD/2
VDD/2
VDD/2
VDD/2
VDD/2
VDD/2
VDD
VSS
6
SEGx
(on)
VSS
VDD
VSS
VDD
VSS
VDD
VSS
VDD
SEGx
(off)
VDD
VSS
VDD
VSS
VDD
VSS
VDD
VSS
Interfacing to LCDs, LEDs and Input Keys with Pin-shared I/Os in the HT66Fx0
Program Example
The program code and description are enclosed.
Conclusion
This example has shown how to drive a 4 * 8 LCD, how to implement input key scanning
and how to drive LEDs. Users only need to apply limited program modifications before
applying the example program to their specific 1/2 bias LCD applications.
7
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement