pic18 LCD interfacing

Post on 30-Oct-2014

589 views 6 download

Tags:

description

ec501,pic18

Transcript of pic18 LCD interfacing

44

MICROCONTROLLER BOARD{ Alphanumeric LCD and Keypad}Mohamad Fauzi Zakaria

http://fkee.uthm.edu.my/mfauzi

ContentsContents2

Hardware Setup for Hitachi HD44780 LCD controller.

Ti i DiTiming Diagram

Command Set

DDRAM Address

hCharacter Pattern

LCD Programmingg g

Function Library for XLCD

SchematicSchematic3

3 January, 2011mfauzi

Timing Diagram4

Timing Diagram

Command Set {1}Command Set {1}5

Command Set {2}Command Set {2}6

Command Set {3}Command Set {3}7

DDRAM ADDRESSDDRAM ADDRESS8

Character Pattern {1}Character Pattern {1}9

Character Pattern {2}Character Pattern {2}10

Character Pattern {3}Character Pattern {3}11

LCD ‐ ProgrammingLCD ‐ Programming12

LCD Subroutine ‐ DriverLCD Subroutine ‐ Driver13

LCD Subroutine ‐ SetupLCD Subroutine ‐ Setup14

Application – Main FunctionApplication – Main Function15

Function Library for XLCDFunction Library for XLCD16

Macros for Selecting LCD Pin Assignments

17

Macros for Selecting Selecting 4 or 8 bit Mode

18

XLCD Delay FunctionsXLCD Delay Functions19

The XLCD libraries also require that the following functions be defined by the user to provide the appropriate delays:defined by the user to provide the appropriate delays:

Example of Use “xlcd h” {1}Example of Use  xlcd.h  {1}20

Example of Use “xlcd h” {2}Example of Use  xlcd.h  {2}21

Example of Use “xlcd h” {3}Example of Use  xlcd.h  {3}22

Keypad23

Keypad

A keypad is simply an array of push buttons connected in rows and columnsin rows and columns.

Two processes of keypad programming: k d t ti1. key press detection

1. Interrupt method2. Scanning method

2. key identification. y

3 January, 2011mfauzi

Interrupt Method Key Press Detection24

Interrupt Method Key Press Detection

If RB3 – RB0 = 1110 for the d RB7 RB4 1011

0

row and RB7 - RB4 = 1011 for the column.

1

1

Then, the key number 2 was 1 0 1 11

Then, the key number 2 was pressed.

1 0 1 1

3 January, 2011mfauzi

25

Scanning Method for Key Press Detection

Flow Chart for Program 12 – 4

3 January, 2011mfauzi

Program 12 4