0% found this document useful (0 votes)
121 views5 pages

Instruction Rs RW D7 D6 D5 D4 D3 D2 D1 D0 Description

The document describes LCD controller commands used to control an LCD display. It lists the various commands, their bit descriptions, and what they are used for. It then provides examples of how higher-level LCD functions like initialization, clearing the screen, and moving the cursor can be implemented using sequences of these lower-level commands. Finally, it describes an LCD library that implements common LCD functions through C function calls, abstracting the underlying command operations.

Uploaded by

harish1991
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views5 pages

Instruction Rs RW D7 D6 D5 D4 D3 D2 D1 D0 Description

The document describes LCD controller commands used to control an LCD display. It lists the various commands, their bit descriptions, and what they are used for. It then provides examples of how higher-level LCD functions like initialization, clearing the screen, and moving the cursor can be implemented using sequences of these lower-level commands. Finally, it describes an LCD library that implements common LCD functions through C function calls, abstracting the underlying command operations.

Uploaded by

harish1991
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

LCD Commands: Instruction NOP RS RW D7 0 0 0 0 0 0 0 0 0 D6 0 0 0 0 D5 D4 D3 0 0 0 0 0 0 0 0 0 0 0 0 D2 D1 D0 Description 0 0 0 No Operation 0 0 1 0 1 1 x Clear Display and Address counter = 0 Address counter = 0 Set cursor

direction(I/D) and auto display shift (S) Turn display (D) and cursor (C) ON/OFF. Set cursor blinking(B) Shift display/cursor (S), specify direction (R/L) Set Interface data width (DL), number of display lines (N), character font (F) Set CGRAM address (D0-D5), CGRAM data is sent after this command Set DDRAM address (D0-D6), DDRAM data is sent after this command Read busy flag (BF) and address counter(D0-D6) Write data (D0-D7) into DDRAM/CGRAM Read data (D0-D7) from

Clear Display 0 Cursor Home 0 Entry mode set 0

I/D S

Display Control

Cursor/ Display shift Function set

R/L x

DL N

Set CGRAM Address

Set DDRAM Address

Busy Flag and 0 Address Write Data 1

BF

Read Data

DDRAM/CGRAM Legends used in table:I/D: 1- Increment, 0- Decrement S: 1- Auto Display shift, 0 No display shift D: 1- Display ON, 0 Display OFF C: 1- Cursor ON, 0- Cursor OFF B: 1- Cursor blinking ON, 0 Cursor blinking OFF S: 1- Display Shift, 0 Cursor move R/L: 1- Shift right, 0- Shift left DL: 1- 8 bit interface, 0- 4 bit interface N: 1- 2 lines, 0- 1 line F: 1- 5X10 dots font, 0- 5X7 dots font BF: Busy Flag LCD Controller (JHD162A, HD44780) Commands All LCD functions are actually a combination of above mentioned commands. We will use some example functions to understand how to use commands to build higher level functionality. 2.1 LCD Initialization: To initialize LCD a typical sequence of commands is followed. We also configure all LCD related parameters such as data interface width, display characteristics etc. in this function. Initialization sequence: 1. Wait for power supplies to stabilize. Wait for approx 2-3 ms 2. Write 030 to LCD 3. wait for 50ms 4. Write 030 to LCD 5. wait for 10ms 6. Write 030 to LCD 7. wait for 1ms 8. Set data interface width (Write 030 for 8 bit or 020 for 4 bit) to LCD 9. wait for 50ms 10. Set display lines and font dots 11. Set Display OFF, Cursor and blinking off (Write 00B) 12. Set Display ON, Cursor and blinking off (Write 00F) 13. Set Cursor move direction (I/D) and display shift (S) 14. Clear display (Write 001) 15. Wait 50ms 2.2 Moving Cursor to Home: To move cursor to home position without clearing the screen we will use following commands 1. Write 003 2. Wait for approx 2ms

Similarly many functions can be implemented using LCD commands. LCD Library available from source code section (bottom of this article) provides following functions using C. Function Description

Utility functions InitializeLCD Initialize LCD hardware ClearScreen Clears LCD screen MoveCursorToHome Moves cursor to home position Cursor functions SetCursorPos Sets cursor position SetCursorState Sets cursor state (Blink,ON/OFF) SetCursorBlink Sets cursor in blinking state SetCursorNoBlink Disables cursor blinking SetCursorOn Cursor enabled SetCursorOff Cursor disabled Writing functions WriteCharAtPos Writes character at defined position WriteStringAtPos Writes string at defined position Custom character/font functions CreateCustomCharacter Creates user defined character LCD Library functions 2.3 Detailed function description:

InitializeLCD Prototype Input parameters Output Description

void InitializeLCD(); None None Initializes LCD hardware. Configures data interface(4bit or 8 bit). Clears the display and places cursor at home with blinking mode

ClearScreen Prototype Input parameters Output Description

void ClearScreen(); None None Clear screen and moves cursor to home. This function takes approx 1.6 ms to complete.

MoveCursorToHome void MoveCursorToHome(); Prototype None Input parameters None Output Moves the cursor to home position Description

SetCursorPos Prototype Input parameters Output Description

void SetCursorPos(unsigned char row, unsigned char col); row: row number (first row = 0 and so on)col: Column number (first column = 0 and so on) None Sets the cursor position to specified row and column position

SetCursorState Prototype Input parameters Output Description

void SetCursorState(unsigned char isBlinking, unsigned char isOn); isBlinking: 0 no blinking, 1- blinkingisOn: 0 cursor OFF, 1cursor ON None Changes cursor state (Blinking and On/Off)

SetCursorBlink Prototype Input parameters Output Description

void SetCursorBlink(); None None Sets cursor blinking

SetCursorNoBlink Prototype Input parameters Output Description

void SetCursorNoBlink(); None None Disables cursor blinking

SetCursorOn Prototype Input parameters Output Description

void SetCursorOn(); None None Enables cursor

SetCursorOff Prototype Input parameters Output Description

void SetCursorOff(); None None Disables cursor

WriteCharAtPos Prototype Input parameters Output Description

void WriteCharAtPos(unsigned char row, unsigned char col, char ch); row: row position, First row =0 and so oncol: column position, First column = 0 and so onch: character to be written None Writes a single character ch at specified row and column position

WriteStringAtPos Prototype Input parameters Output Description

void WriteStringAtPos(unsigned char row, unsigned char col, char *str); row: row position, First row =0 and so oncol: column position, First column = 0 and so onstr: string to be written None Writes character string at specified row and column position

You might also like