CONFIGURACION DE PINES LCD
Estas son algunas de las configuraciones de pines en los diferentes tipos de LCD que existen:

Estas configuraciones distintas responden a la misma función en sus pines numerados de la siguiente forma:

|
|
|
|
|
DL=1: 8 bits interface |
| N=0: 1 line display | |
| F=0: 5x7 dot font | |
|
|
D=0: Display OFF |
| C=0: Cursor OFF | |
| B=0: Blink OFF | |
|
|
I/O=1: +1 increment |
|
|
Power Supply Timing Requirements for Internal Initialization
If power supply rise time cannot be assured of meeting the requirements above, or if different parameters are required (such as for a 2 line display), an initialization routine will have to be sent from the host. When first setting up the display, Densitron recommends the following initialization routines for 8 bit interfaces:
After sending this routine, you should have a clear display with a flashing cursor in the upper left position. The cursor will then increment to the right with each data RAM write command. If, you do not have this display, see Troubleshooting Tips in the appendix.
If a 2-line display has less than 40 characters per line, the cursor will advance off the screen after the last character of the first line. To put data on the secone line, a Set DD RAM Address instruction must be sent.
When instruction
S=1, the display is shifted. This makes the characters look as though they
are marching across the screen on entry. It also lets small displays (2x16s,
for example) to have data stored in non-visible areas of the RAM and shifted
in to view with one command. The last diagram shows how the addresses "wrap"
in this mode.
E. SPECIALLY CODED DISPLAYS
Three types
of displays have different addressing than typical 1 or 2 line displays.
They are:
| 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | C0 | C1 | C2 | C3 | C4 | C5 | C6 | C7 |
4x16/20 - Because of the way the controller and drivers are connected to make maximum use of their outputs, special attention must be paid to the addresses of these displays. Logically, line 3 follows line 1, and line 4 follows line 2. When the cursor gets to the end of line 1, it will jump to line 3. Keeping track of cursor location for proper positioning is important.
| 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 8A | 8B | 8C | 8D | 8E | 8F |
| C0 | C1 | C2 | C3 | C4 | C5 | C6 | C7 | C8 | C9 | CA | CB | CC | CD | CE | CF |
| 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 9A | 9B | 9C | 9D | 9E | 9F |
| D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8 | D9 | DA | DB | DC | DD | DE | DF |
-------- 4 X 20 ----------
| 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 8A | 8B | 8C | 8D | 8E | 8F | 90 | 91 | 92 | 93 |
| C0 | C1 | C2 | C3 | C4 | C5 | C6 | C7 | C8 | C9 | CA | CB | CC | CD | CE | CF | D0 | D1 | D2 | D3 |
| 94 | 95 | 96 | 97 | 98 | 99 | 9A | 9B | 9C | 9D | 9E | 9F | A0 | A1 | A2 | A3 | A4 | A5 | A6 | A7 |
| D4 | D5 | D6 | D7 | D8 | D9 | DA | DB | DC | DD | DE | DF | E0 | E1 | E2 | E3 | E4 | E5 | E6 | E7 |
| Line1 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 8A | 8B | 8C | 8D | 8E | 8F | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | ... | A5 | A6 | A7 |
| Line2 | C0 | C1 | C2 | C3 | C4 | C5 | C6 | C7 | C8 | C9 | CA | CB | CC | CD | CE | CF | D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | ... | E5 | E6 | E7 |
| Line3 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 8A | 8B | 8C | 8D | 8E | 8F | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | ... | A5 | A6 | A7 |
| Line4 | C0 | C1 | C2 | C3 | C4 | C5 | C6 | C7 | C8 | C9 | CA | CB | CC | CD | CE | CF | D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | ... | E5 | E6 | E7 |
|
|
|||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||
| 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 8A | 8B | 8C | 8D | 8E | 8F | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | ... | A5 | A6 | A7 | ... | C5 | C6 | C7 |
|
|
|||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
| 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 8A | 8B | 8C | 8D | 8E | 8F | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | ... | A5 | A6 | A7 |
| C0 | C1 | C2 | C3 | C4 | C5 | C6 | C7 | C8 | C9 | CA | CB | CC | CD | CE | CF | D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | ... | E5 | E6 | E7 |
|
|
|||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||
| 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 8A | 8B | 8C | 8D | 8E | 8F | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | ... | A6 | A7 | 80 |
| C1 | C2 | C3 | C4 | C5 | C6 | C7 | C8 | C9 | CA | CB | CC | CD | CE | CF | D0 | D1 | D2 | D3 | D4 | D5 | D6 | D7 | D8 | ... | E6 | E7 | C0 |
| Instruction | RS | R/W | DB7 | DB6 | DB5 | DB4 | DB3 | DB2 | DB1 | DB0 | Description | Execution Time
(when Fcp or fosc is 250KHz) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Clear Display | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | Clears Display and returns cursor to the Home Position (Address 00) | 80uS = 1.64mS |
| Return Home | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | * | Returns cursor to Home Position. Returns shifted display to original position. Does not clear display | 40uS = 1.6mS |
| Entry Mode Set | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | I/D | S | Sets DD RAM counter to increment or decrement (I/D) Specifies cursor or display shift during to Data Read or Write (S) | 40uS |
| Display ON/OFF Control | 0 | 0 | 0 | 0 | 0 | 0 | 1 | D | C | B | Sets Display ON/OFF (D), cursor ON/OFF (C), and blink character at cursor position | 40uS |
| Cursor or Display Shift | 0 | 0 | 0 | 0 | 0 | 1 | S/C | R/L | * | * | Moves cursor or shifts the display w/o changing DD RAM contents | 40uS |
| Function Set | 0 | 0 | 0 | 0 | 1 | DL | N | F | * | * | Sets data bus length (DL), # of display lines (N), and character font (F) | 40uS |
| Set CG RAM Address | 0 | 0 | 0 | 1 |
|
Sets CG RAM address. CG RAM data is sent and received after this instruction | 40uS | |||||
| Set DD RAM Address | 0 | 0 | 1 |
|
Sets DD RAM address. DD RAM data is sent and received after this instruction | 40uS | ||||||
| Read Busy Flag & Address | 0 | 1 | BF |
|
Reads Busy Flag (BF) and address counter contents | 1uS | ||||||
| SIZE=2>Write Data from DD or CG RAM | 1 | 0 |
|
Writes data to DD or CG RAM and increments or decrements address counter (AC) | 40uS | |||||||
| Read Data from DD or CG RAM | 1 | 1 |
|
Reads data from DD or CG RAM and increments or decrements address counter (AC) | 40uS | |||||||
| I/D=1: Increment
S=1: Display Shift on data entry S/C=1: Display Shift (RAM unchanged) R/L=1: Shift to the Right DL=1: 8 bits N=1: 2 Lines F=1: 5x10 Dot Font D=1: Display ON C=1: Cursor ON B=1: Blink ON BF=1: Cannot accept instruction |
I/D=0: Decrements
S=0: Cursor Shift on data entry S/C=0: Cursor Shift (RAM unchanged) R/L=0: Shift to the Left DL=0: 4 bits N=0: 1 Line F=0: 5x7 Dot Font D=0: Display OFF C=0: Cursor OFF B=0: Blink OFF BF=0: Can accept instruction |
Definitions:
DD RAM: Display data RAM CG RAM: Character generator RAM ACG: CG RAM Address ADD: DD RAM Address(Cursor Address) AC: Address Counter used for both DD and CG RAM Address |
Execution Time changes when Frequency
changes per the following example:
If FCP or fosc is 27 KHz 40uS x 250/270 = 37uS |
|||||||||
CODE
| RS | R/W | DB7 | DB0 | ||||||
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
Writes space code "20" (hexadecimal) into all the DD RAM addresses. The cursor returns to Address 0 (ADD="80") and display, if it has been shifted, returns to the original position. In other words, display disappears and the cursor goes to the left edge of the display (the first line if a 2 or 4 line display module is used).
RETURN HOME
CODE
| RS | R/W | DB7 | DB0 | ||||||
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | * |
Returns the cursor to Address 0 (ADD="80") and display, if it has been shifted, to the original position. The DD RAM contents remain unchanged.
ENTRY MODE SET
CODE
| RS | R/W | DB7 | DB0 | ||||||
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | I/D | S |
I/D: Increments (I/D=1) or decrements (I/D=0) the DD RAM address by one when writing or reading a character code from DD RAM. The cursor moves to the right when incremented by one. The same applies to writing and reading CG RAM.
S: Shifts the entire display to either the right or the left when S is 1; to the left when I/D=1 and to the right when I/D=0. Therefore, the cursor looks as if stood stil while only the display has moved. Display is not shifted when reading from DD RAM. Display is not shifted when S=0.
DISPLAY ON/OFF CONTROL
CODE
| RS | R/W | DB7 | DB0 | ||||||
| 0 | 0 | 0 | 0 | 0 | 0 | 1 | D | C | B |
CURSOR OR DISPLAY SHIFT
CODE
| RS | R/W | DB7 | DB0 | ||||||
| 0 | 0 | 0 | 0 | 0 | 1 | S/C | R/L | * | * |
Shifts the cursor position or display to the right or left without writing or reading the display data. This function is used for correction or search of display.
| S/C | R/L | |
| 0 | 0 | Shifts the cursor position to the
left.
(AC is decremented by one.) |
| 0 | 1 | Shifts the cursor position to the
right.
(AC is incremented by one). |
| 1 | 0 | Shifts the entire display to the
left.
The cursor follows the display shift. |
| 1 | 1 | Shifts the entire display to the
right.
The cursor follows the display shift. |
FUNCTION SET
CODE
| RS | R/W | DB7 | DB0 | ||||||
| 0 | 0 | 0 | 0 | 1 | DL | N | F | * | * |
DL: Sets
interface data length. Data is sent or received in 8 bit length (DB7-DB0)
when DL=1 and 4 bit length (DB7-DB4) when DL=0. When 4 bit length is selected,
data must be sent or received in 2 operations.
N: Sets
number of display lines.
F: Sets
character font.
(Together, N
& F set the duty cycle).
SET CG RAM ADDRESS
CODE
| RS | R/W | DB7 | DB0 | ||||||
| 0 | 0 | 0 | 1 | A | A | A | A | A | A |
SET DD RAM ADDRESS
CODE
| RS | R/W | DB7 | DB0 | ||||||
| 0 | 0 | 1 | A | A | A | A | A | A | A |
Sets the DD RAM address in a binary number of AAAAAAA in the address counter. Data is written or read from the MPU related to the DD RAM after this. When N=0 (1 line display), AAAAAAA is "00" to "47" (hexadecimal) When N=1 (2 line display),
AAAAAAA for the first line is "00" to "27" and "40" to "67", (hexadecimal) for the second line. Because the MSB is set to "!", the hex codes are actually "80" to "C0", "80" to "A7", and "C0" to "E7" respectively. See Display Addressing for more information.
READ BUSY FLAG AND ADDRESS
CODE
| RS | R/W | DB7 | DB0 | ||||||
| 0 | 1 | BF | A | A | A | A | A | A | A |
When BF=1, the system is internally operating on a previously received instruction. The next instruction will not be received until BF=0. The value of the address counter also to read during this operation, and is given in binary AAAAAAA. Whether CG or DD RAM address is read is determined by the previous instruction.
WRITE DATA TO CG OR DD RAM
CODE
| RS | R/W | DB7 | DB0 | ||||||
| 1 | 0 | D | D | D | D | D | D | D | D |
Writes binary 8 bit data DDDDDDD to the CG or the DD RAM. Whether the CG or the DD RAM is to be written is determined by the previous designation (CG RAM address setting or DD RAM address setting). After write, the address is automatically incremented or decremented by one according to entry mode. Display shift also follows the entry mode.
READ DATA FROM CG OR DD RAM
CODE
| RS | R/W | DB7 | DB0 | ||||||
| 1 | 1 | D | D | D | D | D | D | D | D |
Reads binary 8 bit data DDDDDDD from the CG or the DD RAM. Whether the CG RAM or the DD RAM is to be read is determied by the previous designation. Prior to inputting this read instruction, either the CG RAM address set instruction or the DD RAM address set instruction must be executed. If it is not done, the first read data becomes invalid, and data of the next address is read normally from the second read. After read, the address is automatically incremented or decremented by one according to the entry mode. However, display shift is not performed regardless of entry mode types.
NOTE: This is a RAM, and must be reprogrammed if display power is interrupted. If used regularly, programming can be made part of the initialization routine.
There are two distinct areas of RAM within the display module. The main area, 80 bytes wide, is dedicated to the display and is called Display Data (DD) RAM. CG RAM consists of 64 bytes which range from 40 to 7F (hex), or 4 5x10 (or 5x11) symbols. 40-47 locate the first, custom 5x7 character. 40 is the top row of this character, 47 is the 8th row. Similarly, 48-4F locate the second CG character, and 78-7F locate the 8th custom character. The locations 40-7F are the CG "Programming" locations only! Once programmed, these special characters are displayed by writing to character font locations 00-07 (hex). 00 will retun that character residing in locations 40-47, 01 returns 48-4F. etc. (See Font Chart).
While the CG RAM byte is 8 bits wide, only the 5 least significant bits appear on the LCD. Thus D4 represents the left-most dot and D0 the right-most dot. To illustrate, loading a CG RAM byte with 1F turns all dots in that row on; loading a byte with 00 turns all dots off. All 7 or 8 rows must be programmed at each desired CG location.
Programming procedure
is:
a) with RS=0
enter the address of the top row of the character to be programmed (i.e.
40,48,50, etc.)
b) with RS=1
enter pattern data for row 1 (top row)
c) continue
to enter pattern data for rows 2-8; it is not necesary to enter additional
addresses if the module has been initialized with command 06 (auto increment
of cursor).
This procedure
may be continued until all CG bytes have been loaded.
The CG RAM can create an attractivew, "reverse-video" 3 x 5 pattern. Numerals look especially good in this format. Most letters can be executed. The limitation of 8 characters can be circumvented by creating a "library" of custom symbols, each totalling 8, resident in the host system. Eight custom symbols can be displayed at any ONE time. The CG RAM can be periodically reloaded as display requirements change. If you reload a CG location which is currently on the display, the change will be immediately apparent. Displays employing multiple controllers (ie. 4 x 40, 2 x 80. 4 x 80) may create 8 symbols per controller. The CG RAM adds interest and flexibility to the LCD module.
CG RAM, DD RAM, and pattern examples for 5 x 7 Dot Character patterns
| Character Codes
(DD RAM Data) |
CG RAM Address | Character Patterns
(CG RAM Data) |
|---|---|---|
| 7 6 5 4 3 2 1 0
<<Higher order bits Lower order bits >> |
5 4 3 2 1 0
<<Higher order bits Lower order bits >> |
7 6 5 4 3 2 1 0
<<Higher order bits Lower order bits >> |
| 0 0 0 0 * 0 0 0 | 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1 1 0 0 0 0 1 1 1 |
* * * 1 1 1 1 0
* * * 1 0 0 0 1 * * * 1 0 0 0 1 - Character * * * 1 1 1 1 0 - Pattern * * * 1 0 1 0 0 - Example (1) * * * 1 0 0 1 0 * * * 1 0 0 0 1 * * * 0 0 0 0 0 - Cursor Position |
| 0 0 0 0 * 0 0 1 | 0 0 1 0 0 0
0 0 1 0 0 1 0 0 1 0 1 0 0 0 1 0 1 1 0 0 1 1 0 0 0 0 1 1 0 1 0 0 1 1 1 0 0 0 1 1 1 1 |
* * * 1 0 0 0 1
* * * 0 1 0 1 0 * * * 1 1 1 1 1 - Character * * * 0 0 1 0 0 - Pattern * * * 1 1 1 1 1 - Example (2) * * * 0 0 1 0 0 * * * 0 0 1 0 0 * * * 0 0 0 0 0 - Cursor position |
| 0 0 0 0 * 0 1 0 | 0 1 0 0 0 0
0 1 0 0 0 1 |
* * * 1 0 0 0 1
* * * 1 1 0 1 1 |
| 0 0 0 0 * 1 1 1 | 1 1 1 1 0 1
1 1 1 1 1 0 1 1 1 1 1 1 |
* * * 0 0 1 0 0 - Character Pattern
* * * 0 1 0 1 0 - Example (8) * * * 1 1 0 1 1 - Cursor position |
Notes:
| Character Codes
(DD RAM Data) |
CG RAM Address | Character Patterns
(CG RAM Data) |
|---|---|---|
| 7 6 5 4 3 2 1 0
<<Higher order bits Lower order bits >> |
5 4 3 2 1 0
<<Higher order bits Lower order bits >> |
7 6 5 4 3 2 1 0
<<Higher order bits Lower order bits >> |
| 0 0 0 0 * 0 0 * | 0 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 1 0 1 0 0 0 1 1 0 0 0 0 1 1 1 0 0 1 0 0 0 0 0 1 0 0 1 0 0 1 0 1 0 0 0 1 0 1 1 0 0 1 1 0 0 0 0 1 1 0 1 0 0 1 1 1 0 0 0 1 1 1 1 |
* * * 0 0 0 0 0
* * * 0 0 0 0 0 * * * 1 0 1 1 0 * * * 1 1 0 0 1 - Character * * * 1 0 0 0 1 - Pattern * * * 1 0 0 0 1 - Example (1) * * * 1 1 1 1 0 * * * 1 0 0 0 0 * * * 1 0 0 0 0 * * * 1 0 0 0 0 * * * 0 0 0 0 0 - Cursor Position * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 0 0 0 0 * 0 1 * | 0 1 0 0 0 0
0 1 0 0 0 1 |
* 0 1 0 0 0 0 *
* 0 1 0 0 0 1 * |
| 0 0 0 0 * 1 1 * | 1 1 1 1 0 1
1 1 1 1 1 0 1 1 1 1 1 1 |
* * * * * * * * - Character
* * * * * * * * - Pattern * * * * * * * * - Example (4) |