Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Connections of LM16202 LCD display with Atmega32 microcontroller

Status
Not open for further replies.

shom_show

Member level 1
Joined
Feb 28, 2012
Messages
41
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,621
Hi,

I am trying to interface LAMPEX LM16202 16x2 LCD display with ATmega32. But I have doubt about few pin connections which are as follows -

1) pin3 - Vo - Contrast Adjustment

2) pin4 - RS - H/L Register Select Signal

3) pin5 - R/W - H/L Read/Write Signal

4) pin6 - E - H → L Enable Signal

5) pin15 - A/Vee - + 4.2V for LED/Negative Voltage Output (Can we apply 5 volt supply here?)

6) pin16 - K - Power Supply for B/L (OV)

Can anyone please give me some informations regarding the above connections.


Sumanta
 

Hi to all,



I am trying to do programming for display in LCD display. The program is as below -


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Program to display a single alphabet ‘A’ on LCD 
/*
LCD data transfer through 8 bit mode
Writing a single letter A on LCD
 
LCD DATA port----PORT A
ctrl port------PORT B
rs-------PB0
rw-------PB1
en-------PB2
*/
 
#include<avr/io.h>
#include<util/delay.h>
#ifndef F_CPU
#define F_CPU 16000000UL
#endif
 
#define LCD_DATA PORTA // LCD data port
#define ctrl PORTB
#define en PB2 // enable signal
#define rw PB1 // read/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; // making LCD_DATA port as output port
DDRB=0x07; // making signal as out put
init_LCD(); // initialization of LCD
_delay_ms(50); // delay of 50 milli seconds
//LCD_write('B'); // call a function to write A on LCD
LCD_string();
return 0;
}
 
void init_LCD(void)
{
LCD_cmd(0x38); // initialization of 16X2 LCD in 8bit mode
_delay_ms(1);
 
LCD_cmd(0x01); // clear LCD
_delay_ms(1);
 
LCD_cmd(0x0E); // cursor ON
_delay_ms(1);
 
LCD_cmd(0x80); // ---8 go to first line and --0 is for 0th position
_delay_ms(1);
return;
}
 
void LCD_cmd(unsigned char cmd)
{
LCD_DATA=cmd;
ctrl =(0<<rs)|(0<<rw)|(1<<en); // RS and RW as LOW and EN as HIGH
_delay_ms(1);
ctrl =(0<<rs)|(0<<rw)|(0<<en); // RS, RW , LOW and EN as LOW
_delay_ms(50);
return;
}
 
void LCD_write(unsigned char data)
{
LCD_DATA= data;
ctrl = (1<<rs)|(0<<rw)|(1<<en); // RW as LOW and RS, EN as HIGH
_delay_ms(1);
ctrl = (1<<rs)|(0<<rw)|(0<<en); // EN and RW as LOW and RS HIGH
_delay_ms(50); // delay to get things executed
return ;
}
 
void LCD_string(void)
{
unsigned char str[] = "Hi This is Biswajit Manna";
int i;
for(i=0;i<16; i++)
{
LCD_DATA = str[i];
ctrl = (1<<rs)|(0<<rw)|(1<<en); // RW as LOW and RS, EN as HIGH
_delay_ms(1);
ctrl = (1<<rs)|(0<<rw)|(0<<en); // EN and RW as LOW and RS HIGH
_delay_ms(50); // delay to get things executed
}
if (i==16)
{
 
LCD_cmd(0xC0); // ---C go to 2nd line and --0 is for 0th position
_delay_ms(1);
for (i=16;i<sizeof str;i++)
{
LCD_DATA = str[i];
ctrl = (1<<rs)|(0<<rw)|(1<<en); // RW as LOW and RS, EN as HIGH
_delay_ms(1);
ctrl = (1<<rs)|(0<<rw)|(0<<en); // EN and RW as LOW and RS HIGH
_delay_ms(50); // delay to get things executed
}
}
return;
}




Tell me if there is anything wrong in the program. Some display is coming in the LCD but not in accordance with the string specified in the program. Yours help will be highly appreciated.
 
Last edited by a moderator:

Hi,
Your function definition contains error
in the set_lcd_commad(unsigned char)
1 select the register for command mode i.e. RS=0
2 then assign the formal argument value to LCD_DATA pin
3 lcd_clock high
4 give some delay
5 lcd_clock low
6 give some delay

Do the same in set_lcd_data(unsigned char) except RS ,here set RS =1 for data mode

and check whether you are getting your desired output or not?
i think this will help you and ur code will work perfectly
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top