Presentation is loading. Please wait.

Presentation is loading. Please wait.

GANDHINAGAR INSTITUTE OF TECHNOLOGY

Similar presentations


Presentation on theme: "GANDHINAGAR INSTITUTE OF TECHNOLOGY"— Presentation transcript:

1 GANDHINAGAR INSTITUTE OF TECHNOLOGY
Active Learning Assignment Sub:- Microcontroller and Interfacing Topic:- LCD Interfacing with ATMega32 Branch :- Electronics & Communication

2 Group Members:- Faculty-In-charge Prof. Hardik Patel Arshiya Maniar
Zulin Patel Riya Simon Faculty-In-charge Prof. Hardik Patel

3 LCD Interfacing with ATMega32

4 Contents Displays LCD displays Advantages of LCD displays
Pin description of LCD LCD command codes Sending commands and data to LCD Sending 8-bit data to LCD Programming in ‘C’ language References

5 Displays If keyboard are the predominant means of interface to human input, then visible displays are the universal means of human output. Displays can be grouped in to three broad categories: Single light (e.g. LED Indicators) Single character (e.g. seven segment display) Intelligent alphanumeric (e.g. LCD display)

6 LCD displays LCD (Liquid Crystal Display) type displays, provide a very convenient way of displaying information or digital data in the form of numbers, letters or even alpha-numerical characters. LCD displays have one major advantage over similar LED types in that they consume much less power. Nowadays both LCD and LED displays are combined together to form larger Dot-Matrix Alphanumeric type displays which can show letters and characters as well as numbers in standard Red or Tri-color outputs.

7 Advantages of LCD displays
LCD’s are finding widespread use replacing seven segment LEDs or multisegment LEDs. This is due to following reasons: The declining prices of LCDs. The ability to display number, character, and graphics. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of the task of refreshing the LCD. Ease of programming for characters and graphics. The declining prices of LCDs The ability to display number, character, and graphics. This is in contrast to LEDs, which are limited to numbers and a few characters. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of the task of refreshing the LCD. In contrast, the LED must be refreshed by the CPU to keep displaying the data. Ease of programming for characters and graphics.

8 Pin description of LCD display

9 Power supply to control Contrast 4 RS
Pin No. Name Description 1 VSS Power supply (GND) 2 VCC Power supply (+5V) 3 VEE Power supply to control Contrast 4 RS 0 = Instruction input / 1 = Data input 5 R/W 0 = Write to LCD module / 1 = Read from LCD module 6 EN Enable signal 7 D0 Data bus line 0 (LSB) 8 D1 Data bus line 1 9 D2 Data bus line 2 10 D3 Data bus line 3 11 D4 Data bus line 4 12 D5 Data bus line 5 13 D6 Data bus line 6 14 D7 Data bus line 7 (MSB) Rs = register select

10 LCD Command Codes Code (Hex) Command to LCD Instruction (Register) 1
Clear display 2 Return home 4 Decrement cursor (shift cursor to left) 6 Increment cursor (shift cursor to right) 5 Shift display 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

11 LCD command codes (Cont’d)
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 beginningof first line C0 Force cursor to beginning of second line 28 38

12 Sending commands and data to LCD

13 Sending commands and data to LCD (Cont’d)

14 Sending 8-bit data to LCD
To write “Hello” on the LCD using 8-bit data. Interfacing LCD with atmega32 LCD Connections for 8-bit Data

15 LCD PROGRAMMING IN ASSEMBLY LANGUAGE
. INCUDE “M32DEF.INC” .EQU LCD_DPRT = PORTA .EQU LCD_DDDR = DDRA .EQU LCD_DPIN = PINA .EQU LCD_CPRT = PORTB .EQU LCD_CDDR = DDRB .EQU LCD_CPIN = PINB .EQU LCD_RS = 0 .EQU LCD_RW = 1 .EQU LCD_EN = 2 LDI R21, HIGH (RAMEND) OUT SPH,R21 LDI R21,LOW (RAMEND) LDI SPL,R21 RAMEND = last location of RAM

16

17

18

19 LCD programming in ‘C’ language
 #include<avr/io.h> #include<util/delay.h> #define lcd_data PORTA        // LCD data port #define ctrl PORTB #define en PB2         // enable signal #define rw PB1         // read or write signal #define rs PB0         // register select signal void lcd_cmd(unsigned char cmd); void init_lcd(void); void lcd_write(unsigned char data);

20 int main() { DDRA=0xFF; DDRB=0x07; init_lcd(); // initialization of LCD _delay_ms(50); // delay of 50ms lcd_write_string(“Hello"); // prints string on LCD return 0; } void init_lcd(void) lcd_cmd(0x38); // LCD initialization _delay_ms(1); lcd_cmd(0x01); // clear LCD

21  lcd_cmd(0x0E);     // cursor ON
    _delay_ms(1);     lcd_cmd(0x80);    // ---8 go to first line and --0 is for 0th position     return; }  void lcd_cmd(unsigned char cmd) {     lcd_data=cmd;     ctrl =(0<<rs)|(0<<rw)|(1<<en);         ctrl =(0<<rs)|(0<<rw)|(0<<en);         _delay_ms(50);

22 void lcd_write(unsigned char data) { lcd_data= data; ctrl = (1<<rs)|(0<<rw)|(1<<en); _delay_ms(1); ctrl = (1<<rs)|(0<<rw)|(0<<en); _delay_ms(50); return ; } void lcd_write_string(unsigned char *str) //store address value of the string in pointer *str int i=0; while(str[i]!='\0‘) // loop will go on till the NULL character in the string { lcd_write(str[i]); // sending data on LCD byte by byte i++; } return;

23 References AVR microcontroller and embedded system – Muhammad Ali Mazidi, Sepehr Naimi, and Sarmad Naimi. The 8051 microcontroller architecture, programming and its applications – Kenneth J Ayala of Western Carolina University. LCDdisplay/bin_3.html

24 Thank You…


Download ppt "GANDHINAGAR INSTITUTE OF TECHNOLOGY"

Similar presentations


Ads by Google