Вы находитесь на странице: 1из 5

Title: Program for LCD and Key-Board Aim: - Write a program to interface keyboard and LCD to micro-controller.

Detect the pressed


key and display on LCD.

Part list:
1. 2. 3.

SPJ board. (LPC2148). Power Supply. Serial cable.

Functions:1.

Void DisplayRow (int row, char *str):pass pointer to 16 character string displays the message on line1 or line2 of LCD, depending on whether row is 1 or 2.

2.

LcdInit( );

LCD Commands for Initialization HD44780 instruction set Code R/ W RS DB 7 0 0 Executio n Time**

Instruction

DB6

DB5 DB4 DB3

DB2 DB1 DB0

Description

Clear display

Clear display and returns cursor to the 1.64mS home position (address 0) Returns cursor to home position (address 0). Also returns 1.64mS display

Cursor home

0 0

Entry mode set

0 0 0

I/D

Display On/Off control

0 0 0

Cursor/disp lay shift

0 0 0

S/C

R/L

being shifted to original position. DDRAM contents remains unchanged. Sets cursor move direction (I/D), specifies to shift the display (S). 40uS These operations are performed during data read/write. Sets On/Off of all display (D), cursor On/Off (C) 40uS and blink of cursor position character (B). Sets cursormove or displayshift(S/C), shift Direction 40uS (R/L). DDRAM contents remains unchanged. Sets interface data length (DL), 40uS number of

Function set

DL

0 0 display line (N) and character.

address

0 0

CGRAM

Set DDRAM address

0 1

DDR AM addr ess

Read busyflag and address counter

1 BF

DDR AM addr ess

Write to CGRAM or DDRAM Read from CGRAM or DDRAM

Wri te data read data

Data is sent 40uS or received after this setting. Sets the DDRAM address. data is sent 40uS or received after this setting. Reads Busyflag(BF) indicating internal operation is being 0uS performed and reads address counter contents Writes data to CGRAM 40uS or DDRAM. Reads data from CGRAM or DDRAM

40uS

Notes:

DDRAM = Display Data RAM. CGRAM = Character Generator RAM. DDRAM address corresponds to cursor position. Address Counter is used for both DDRAM and CGRAM.

* = Dont care. ** = Based on Fosc = 250 KHz. Bit names

Bit I/D S D C B S/C R/L DL N F BF

Settings 0 = Decrement cursor position 0 = No display shift 0 = Display off 0 = Cursor off 0 = Cursor blink off 0 = Move cursor 0 = Shift left 0 = 4-bit interface 0 = 1/8 or 1/11 Duty ( 1 line ) 0 = 5 * 7 dots 0 = Can accept instruction 1= Increment cursor position 1 = Display shift 1 = Display on 1 = Cursor on 1 = Cursor blink on 1 = Shift display 1 = Shift right 1 = 8-bit interface 1 = 1/16 Duty (2 lines) 1 = 5 * 10 dots 1 = Internal operation in progress

Algorithm:
1. 2. 3. 4.

Initialize LCD Display SPJ Embedded on first line and Technologies on second line. Enter into infinite loop Check if sw1 key is pressed
a. b.

If yes, display sw1 pressed. If no, go to next step. If yes, display sw2 pressed. If no, go to next step.

5.

Check if sw2 key is pressed


a. b.

6.

Check if sw3 key is pressed


a. b.

If yes, display sw3 pressed. If no, go to next step. If yes, display sw4 pressed. If no, go to next step. If yes, display sw5 pressed. If no, go to next step. If yes, display sw6 pressed. If no, go to next step. If yes, display sw7 pressed. If no, go to next step. If yes, display sw8 pressed. If no, go to 3rd step.

7.

Check if sw4 key is pressed


a. b.

8.

Check if sw5 key is pressed


a. b.

9.

Check if sw6 key is pressed


a. b.

10.

Check if sw7 key is pressed


a. b.

11.

Check if sw8 key is pressed


a. b.

Conclusion:
Thus we have studied interfacing of keyboard and LCD with micro controller, LPC2148.

Вам также может понравиться