0% found this document useful (0 votes)
44 views3 pages

Driving An LCD Via The Sixteen From Four' Port Expansion Circuit

The document describes commands for controlling an LCD display connected to a microcontroller via a 74HC595 port expander. It explains the purpose and bit patterns for commands that clear the display, move the cursor, set display properties like lines and font size, and set addresses for writing data and custom characters to the LCD's memory. Functions in an LCD library are mapped to each command.

Uploaded by

Phan Luân
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 PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views3 pages

Driving An LCD Via The Sixteen From Four' Port Expansion Circuit

The document describes commands for controlling an LCD display connected to a microcontroller via a 74HC595 port expander. It explains the purpose and bit patterns for commands that clear the display, move the cursor, set display properties like lines and font size, and set addresses for writing data and custom characters to the LCD's memory. Functions in an LCD library are mapped to each command.

Uploaded by

Phan Luân
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 PDF, TXT or read online on Scribd
You are on page 1/ 3

Driving an LCD via the ‘Sixteen from four’ port expansion circuit

Introduction
The library assumes that the R/W pin on the LCD module is tied to ground, as it is on the
printed circuit board for the project. It is therefore omitted from the descriptions that
follow.
Before a command can be sent to the LCD it is necessary to ensure that RS has been set
low: it is this that tells the LCD that the next byte constitutes a command.
Key:
1: high logic level
0: low logic level
X: don’t care

Clear display and home cursor


This command erases the contents of the display and returns the cursor to the first
position on the top row.

RS D7 D6 D5 D4 D3 D2 D1 D0

0 0 0 0 0 0 0 0 1

Command: void com74hc595_lcd_clear(void)

Home cursor
This command returns the cursor to the home position. If the display has been shifted,
the shift offset is also reset.

RS D7 D6 D5 D4 D3 D2 D1 D0

0 0 0 0 0 0 0 1 x

Command: void com74hc595_lcd_home(void)

Cursor direction and display shift


This command is used to set the direction of cursor movement and to enable or disable
display shifting. ‘Shifting’ means that the entire content of the display is scrolled by one
character position.
C = 0: Move cursor to the left
C = 1: Move cursor to the right
S = 0: Shift disabled
S = 1: Shift enabled

RS D7 D6 D5 D4 D3 D2 D1 D0

0 0 0 0 0 0 1 C S

Command: void com74hc595_lcd_CursorMovement( unsigned char C, unsigned char S )


Display status
This command allows the display to be turned on and off, the cursor to be displayed or
suppressed, and the cursor to be shown as blinking or steady.
P = 0: Display off
P = 1: Display on
C = 0: Cursor off
C = 1: Cursor on
B = 0: Steady cursor
B = 1: Blinking cursor

RS D7 D6 D5 D4 D3 D2 D1 D0

0 0 0 0 0 1 P C B

Command: void com74hc595_lcd_DisplayState(uint8_t p, uint8_t c, uint8_t b )

Cursor functions
This command determines whether the cursor moves or whether the display shifts when
a character is written, and in which direction.
M = 0: Cursor moves
M = 1: Display shifts
S = 0: Shift to the left
S = 1: Shift to the right

RS D7 D6 D5 D4 D3 D2 D1 D0

0 0 0 0 1 M S x x

Command: void com74hc595_lcd_CursorState(uint8_t m, uint8_t s)

Display settings
This command determines (among other things) whether communication with the LCD is
carried out in four-bit mode or in eight-bit mode.
B = 0: Four-bit mode
B = 1: Eight-bit mode
N = 0: One line
N = 1: Two lines
F = 0: 5 × 7 pixel characters
F = 1: 5 × 10 pixel characters

RS D7 D6 D5 D4 D3 D2 D1 D0

0 0 0 1 B N F x x

Command: void com74hc595_lcd_DisplayProperties(uint8_t b, uint8_t n, uint8_t f )


Set address in character generator table
This command sets the address for writing user-defined characters into the display’s
character generator table.

RS D7 D6 D5 D4 D3 D2 D1 D0

0 0 1 A5 A4 A3 A2 A1 A0

Command: not implemented

Set address in data memory


This command sets the address for subsequent data register write commands, which will
store characters in the display buffer memory.

RS D7 D6 D5 D4 D3 D2 D1 D0

0 1 A6 A5 A4 A3 A2 A1 A0

Command: void com74hc595_set_cursor(uint8_t x, uint8_t y)

Write to memory
The given data will be written to the most recently selected area of memory.

RS D7 D6 D5 D4 D3 D2 D1 D0

1 D7 D6 D5 D4 D3 D2 D1 D0

Command: not implemented

You might also like