Lcd interface with atmega32 avr best.ppt

SoumyaGupta836456 136 views 24 slides Apr 25, 2024
Slide 1
Slide 1 of 24
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24

About This Presentation

Lcd interface with atmega32


Slide Content

Active Learning Assignment
Sub:-Microcontroller and
Interfacing
Topic:-LCD Interfacing with
ATMega32
Branch :-Electronics & Communication

Arshiya Maniar 130120111014
Zulin Patel 130120111021
Riya Simon 130120111024
Faculty-In-charge
Prof. Hardik Patel

Displays
LCDdisplays
AdvantagesofLCDdisplays
PindescriptionofLCD
LCDcommandcodes
SendingcommandsanddatatoLCD
Sending8-bitdatatoLCD
Programmingin‘C’language
References

Ifkeyboardarethepredominantmeansofinterfacetohumaninput,
thenvisibledisplaysaretheuniversalmeansofhumanoutput.
Displayscanbegroupedintothreebroadcategories:
1)Singlelight(e.g.LEDIndicators)
2)Singlecharacter(e.g.sevensegmentdisplay)
3)Intelligentalphanumeric(e.g.LCDdisplay)

LCD(LiquidCrystalDisplay)typedisplays,provideavery
convenientwayofdisplayinginformationordigitaldatainthe
formofnumbers,lettersorevenalpha-numericalcharacters.
LCDdisplayshaveonemajoradvantageoversimilarLEDtypesin
thattheyconsumemuchlesspower.
NowadaysbothLCDandLEDdisplaysarecombinedtogetherto
formlargerDot-MatrixAlphanumerictypedisplayswhichcan
showlettersandcharactersaswellasnumbersinstandardRedor
Tri-coloroutputs.

LCD’sarefindingwidespreadusereplacingsevensegmentLEDsor
multisegmentLEDs.Thisisduetofollowingreasons:
ThedecliningpricesofLCDs.
Theabilitytodisplaynumber,character,andgraphics.
IncorporationofarefreshingcontrollerintotheLCD,thereby
relievingtheCPUofthetaskofrefreshingtheLCD.
Easeofprogrammingforcharactersandgraphics.

Pin No.Name Description
1 VSS Power supply (GND)
2 VCC Power supply (+5V)
3 VEE Powersupply 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)

Code (Hex) Command to LCD Instruction (Register)
1 Clear display
2 Return home
4 Decrementcursor (shift cursor to left)
6 Incrementcursor (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 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 beginningof first line
C0 Force cursor to beginning of second line
28
38

•Towrite“Hello”ontheLCDusing8-bitdata.
LCD Connections for 8-bit Data

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

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);

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
_delay_ms(1);

lcd_cmd(0x0E);//cursorON
_delay_ms(1);
lcd_cmd(0x80);//---8gotofirstlineand--0isfor0thposition
_delay_ms(1);
return;
}
void lcd_cmd(unsigned char cmd)
{
lcd_data=cmd;
ctrl =(0<<rs)|(0<<rw)|(1<<en);
_delay_ms(1);
ctrl =(0<<rs)|(0<<rw)|(0<<en);
_delay_ms(50);
return;
}

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;
}

AVRmicrocontrollerandembeddedsystem–MuhammadAli
Mazidi,SepehrNaimi,andSarmadNaimi.
The8051microcontrollerarchitecture,programmingandits
applications–KennethJAyalaofWesternCarolinaUniversity.
http://www.electronics-tutorials.ws/LCDdisplay/bin_3.html
Tags