Lcd(nabilah)

  • Uploaded by: Goai Teck Liang
  • 0
  • 0
  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Lcd(nabilah) as PDF for free.

More details

  • Words: 792
  • Pages: 4
Title : Interfacing LCD with microcontroller Name: Siti Nor Nabilah binti Yahya Date : 23 March 2009 Abstract Liquid crystal displays (LCDs) are a passive display technology. This means they do not emit light because they use the ambient light in the environment. By manipulating this light, they display images using very little power. This has made LCDs the preferred technology whenever low power consumption and compact size are critical. This application note explains how LCD is used to display a character. The main scope of this application note is to describe how LCD interfaces with microcontroller. It also will teach simple programming code for LCD interfacing. Keywords LCD Introduction In this application note liquid crystal display JHD 162A is used to interfacing with microcontroller. In interfacing the LCD, the major task is the initialization sequence. Therefore we have to send command bytes to the LCD to set the interface mode, display mode, address counter, increment direction, set contrast of LCD and horizontal or vertical addressing mode. Objective To describe how liquid crystal display(LCD) interface wit microcontroller. Function of JHD 162A Pin No 1 2 3

Name Vss Vdd Vee

Function Ground +ve Supply Contrast

4

RS

Register Set

5

R/W

Read / Write

6

E

Enable

Use 5v Volts Regulated DC This is used to set the contrast1 Register select signal:Instruction register (when writing) Busy flag & address counter (When reading):Data register (when writing & reading) Read/write select signal for writing and for reading Operation (data read/write) enable

Title : Interfacing LCD with microcontroller Name: Siti Nor Nabilah binti Yahya Date : 23 March 2009 signal 7 8 9 10 11 12 13 14 15

D0 D1 D2 D3 D4 D5 D6 D7 LED +

Data Bit 0 Data Bit 1 Data Bit 2 Data Bit 3 Data Bit 4 Data Bit 5 Data Bit 6 Data Bit 7 5 V of backlight

16

LED -

0V of backlight

Positive supply for back light if available

JHD 162A interfacing with microcontroller circuit

Circuit discription Connect pins RS ,RW ,E ,D0 - D7 to pins on the micro controller and connect Data bus on port A and the RS , RW , E on port B . We can save pins by using LCD in Nibble Mode (4 data pins ) and permanently grounding the RW line ( always in write mode ). To avoid losing battery we can ignore the connection of pin 15 and 16 of the LCD.

Title : Interfacing LCD with microcontroller Name: Siti Nor Nabilah binti Yahya Date : 23 March 2009 Using C programming for interfacing Function void initialize ()

Procedure First the Ports to which the LCD are set to output Then the data Port is given the value 0b00111111 then the lcd port is pulsed 3 times to accept the data . After that the Data command 0b00111011 is sent for a 2 line display 5x7 character set etc Then the data command for shift is sent At last the screen is cleared and a delay is made for it to take place

Code /*LCD_DATA_PORT = 0x00;*/ LCD_DATA_DDR = 0xff; LCD_CONTROL_DDR=0xff; LCD_DATA_PORT = 0b00111111; pulse_enable(); lcd_delay(100); pulse_enable(); lcd_delay(100); pulse_enable(); lcd_delay(100); lcd_write_byte(CTRL,0b00111011); lcd_write_byte(CTRL,0b00001100); lcd_write_byte(CTRL,0b00000001); lcd_delay(100); lcd_write_byte(CTRL,0b00000110); //lcd_delay(100);

void cls()

Clear screen This send the Clear screen command to the LCD void lcd_write_byte(unsigned This command writes the char control, unsigned char appropriate byte to the lcd byte)* setting the RS line appropriately for a register or a command as passed The Port is set to the data which is to be sent and the RS line is set for Command or Data and the it is Pulsed

lcd_write_byte(CTRL,0x01); lcd_delay(50);

void pulse_enable()

LCD_CONTROL_PORT LCD_EN_NO; asm("nop LCD_CONTROL_PORT ~LCD_EN_NO; lcd_delay(2);

This command sets the lcd enable line high for a short period of time which make the Lcd to Accept the data or command at its ports

LCD_DATA_PORT = byte ; if (control == DATA ) LCD_CONTROL_PORT |= LCD_RS_NO; else LCD_CONTROL_PORT &= ~LCD_RS_NO; pulse_enable(); lcd_delay(2);

|= "); &=

Title : Interfacing LCD with microcontroller Name: Siti Nor Nabilah binti Yahya Date : 23 March 2009 void lcd_str(char *ptr)

This is used to print a line of text on the lcd void lcd_goto(unsigned char This is used to set the column, unsigned char line) LCD's current cursor from where it will continue printing This 40 is the address of the next line to be added it is OR'ed with 0x80 to make the MSB 1 .

while (*ptr != 0x00) lcd_write_byte(DATA,*ptr++); unsigned char addr; line--; column--; addr = (line * 0x40) + column; lcd_write_byte(CTRL, addr | 0x80);

Conclusion This application note has explained the detail how LCD can be interfacing by showing the circuit diagram and the example and the description of simple c programming for the interfacing with microcontroller.

More Documents from "Goai Teck Liang"