Você está na página 1de 25

LCD interfacing

LCD HD44780U Hardware configuration LCD pin description LCD command codes LCD data sheet Timing graph Write command sequence Read command sequence

Tessolve Training Development Institute

LCD
LCD 16x2 and 20x2 are preferred HD44780U communication between LCD and 8051 HD44780U 3 control lines , 4 or 8 I/O lines for data bus

Tessolve Training Development Institute

HD44780U

4 bit or 8 bit data bus is user selectable 4 bit data bus requires 7 data lines (3 control lines + 4 lines of data bus) 8 bit data bus requires 11 data lines (3 control lines + 8 lines of data bus) Control lines Enable (EN) Register Select (RS) Read/Write (RW)

Tessolve Training Development Institute

Hardware configuration
8 bit mode

Tessolve Training Development Institute

4 bit mode

Tessolve Training Development Institute

LCD pin descriptions

Pin 1 2 3 4 5 6 7 8 9 10 11 12 13 14

Symbol GND Vcc


VEE

RS R/W E DB0 DB1 DB2 DB3 DB4 DB5 DB6 DB7

I/O I I I/O I/O I/O I/O I/O I/O I/O I/O I/O

Description Ground +5V power supply Contrast control command/data register selection write/read selection Enable The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus The 8-bit data bus

Tessolve Training Development Institute

LCD command codes


Code (hex) Command to LCD Instruction Register 1 Clear display screen 2 Return home 4 Shift cursor to left 5 Shift display right 6 Shift cursor to right 7 Shift display left 8 Display off, Cursor off A Display off, Cursor on C Display on, cursor off E Display on, cursor blinking F Display on, cursor blinking 10 Shift cursor position to left 14 Shift cursor position to right 18 Shift the entire display to the left 1C Shift the entire display to the right 80 Force cursor to beginning of 1st line C0 Force cursor to beginning of 2nd line 38 2 lines and 5x7 matrix

Tessolve Training Development Institute

LCD data sheet


RS RW D7 D6 D5 D4 D3 D2 D1 D0 Description 0 0 0 0 0 0 0 0 0 0 No Operation Clears display & sets address counter to Clear Display 0 0 0 0 0 0 0 0 0 1 zero. Sets address counter to zero, returns shifted display to original position. Cursor Home 0 0 0 0 0 0 0 0 1 0 DDRAM contents remains unchanged. Sets cursor move direction, and specifies Entry Mode Set 0 0 0 0 0 0 0 1 I/D S automatic shift. Turns display (D), cursor on/off (C) or Display Control 0 0 0 0 0 0 1 D C B cursor blinking(B). Moves cursor and shift display. DDRAM Cursor/display shift 0 0 0 0 0 1 S/C R/L 0 0 contents remains unchanged. Sets interface data width(DL), number of display lines (N,M) and voltage generator Function Set 0 0 0 0 1 DL N M G 0 control (G). Character Generator Set CGRAM RAM Addr 0 0 0 1 Sets CGRAM Address Set DDRAM 0 0 1 Display Data RAM Address Sets DDRAM Address Addr Busy Flag & Addr 0 1 BF Address Counter Reads Busy Flag & Address Counter Read Data 1 0 Read Data Reads data from CGRAM or DDRAM Instruction NOP Clocks 0 165

3 3 3 3

3 3 3 0 3

Tessolve Training Development Institute

LCD data sheet

Tessolve Training Development Institute

Timing graph

Tessolve Training Development Institute

Write command sequence


Make RS Register Select pin to 'LOW' Make RW- Low to write data to LCD Place the command to be sent on the Port pins Strobe the enable pin from high to low

Tessolve Training Development Institute

LCD Write control function


void LCD_Write_Control (unsigned char D) { unsigned char DL,DH; DH = (D & (0xF0)); // Get High nibble in P2.7 -> P2.4 DL = (D & (0x0F))<<4; // Get Low nibble in P2.7 -> P2.4 LCD_RS = 0; //LCD_RW=0; LCD_Enable = 1 ; LCD_Data=DH ; LCD_Enable = 0 ; LCD_Delay(); LCD_Enable = 1 ; //LCD_Delay(); LCD_Data = DL ; LCD_Enable = 0 ; LCD_Delay(); LCD_Enable = 1 ; }

// Send the 'High nibble' // introduce short delay // introduce short delay // Send the 'Low nibble' // introduce short delay

Tessolve Training Development Institute

12

LCD Write Data Function


void LCD_Write_Data (unsigned char D) { unsigned char DL,DH; DH = (D & (0xF0)); // Get High nibble in P2.7 -> P2.4 DL = (D & (0x0F))<<4; // Get Low nibble in P2.7 -> P2.4 LCD_RS = 1; //LCD_RW=0; LCD_Enable = 1 ; LCD_Data=DH ; // Send the 'High nibble' LCD_Enable = 0 ; LCD_Delay(); // introduce short delay LCD_Enable = 1 ; //LCD_Delay(); // introduce short delay LCD_Data = DL ; // Send the 'Low nibble' LCD_Enable = 0 ; // introduce short delay LCD_Delay(); LCD_Enable = 1 ; }

Tessolve Training Development Institute

13

LCD initialization function


void LCD_Init (void){ LCD_Write_Control (0x28); // Function set in 4 bit mode LCD_Delay(); LCD_Delay(); LCD_Write_Control (0x28); // Function set in 4 bit mode LCD_Delay(); LCD_Delay(); LCD_Write_Control (0x0E); // Display On cursor blink LCD_Delay(); LCD_Delay(); LCD_Write_Control (0x01); // // Clear Display LCD_Delay(); LCD_Delay(); LCD_Write_Control (0x01); // // Clear Display LCD_Delay(); LCD_Delay(); }

Tessolve Training Development Institute

14

Write data sequence


Make RS Register Select pin to 'HIGH' Make RW- Low to write data to LCD Place the command to be sent on the Port pins Strobe the enable pin from high to low

Tessolve Training Development Institute

7segment display interfacing

Tessolve Training Development Institute

16

7segment display interfacing

Tessolve Training Development Institute

17

Sample program to interface 7-segment LED


#include<reg51.h> sbit LedSegCtrl = P0^1; void main() { unsigned char SegLed_7[16] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x98,0x88,0x83,0xC6,0xA1,0x84,0x8E}; unsigned char count; unsigned int i ; LedSegCtrl = 0; while(1) { for (count = 0;count <16;count++) { P2 = SegLed_7[count]; for (i=0;i<35000;i++); } } }

Tessolve Training Development Institute

18

ADC Interfacing

ADC0809 Features
8 bit ADC (Resolution 8 bits ) Input Channels 8 Interface Type ---Parallel Max Sample Rate 10 ksps Supply Voltage 4.5 Volt to 6 Volt External Reference Source Operating Temperature Min -40 deg C to 85 deg C

Tessolve Training Development Institute

20

ADC0809 block diagram

Tessolve Training Development Institute

21

ADC0809 pin diagram


Pin diagram 0809

Tessolve Training Development Institute

22

ADC channel selection

Tessolve Training Development Institute

23

ADC0809 Vref
Relationship between Vref and Vin

Tessolve Training Development Institute

24

ADC0809 timing diagram

Tessolve Training Development Institute

25

Você também pode gostar