Problem with 16x1 LCD display

shindehari

May 19, 2014
14
Joined
May 19, 2014
Messages
14
Dear all,

I am facing problem with interfacing ATMEGA16A to the 16x1 LCD display. I have used same program as listed below for 16x4 LCD display and it is working perfectly but it is not working with 16x1 LCD display.

The code is



#include <avr/io.h>
#include <avr/interrupt.h>

#define F_CPU 8000000UL

void lcd_cmd(int);
void lcd_data(int);

int i=0;

int main(void)
{
DDRA=0xFF;// LCD data lines
DDRB=0xFF;// B7-RS, B6-RW, B5-EN (Command lines)
PORTA=0x00;
PORTB=0x00;

lcd_cmd(0x30);
for(i=0;i<100;i++);
lcd_cmd(0x0E);
for(i=0;i<100;i++);
lcd_cmd(0x01);
for(i=0;i<100;i++);
lcd_cmd(0x04);
for(i=0;i<100;i++);
lcd_cmd(0x80);
for(i=0;i<100;i++);
lcd_data('A');
while(1);
}
void lcd_cmd(int cmd){
PORTA=cmd;
PORTB=0x20;
for(i=0;i<200;i++);
PORTB=0x00;
for(i=0;i<200;i++);
}
void lcd_data(int data){
PORTA=data;
PORTB=0xA0;
for(i=0;i<200;i++);
PORTB=0x80;
for(i=0;i<200;i++);
}

Please help me to find out where i am going wrong.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
14,271
Joined
Nov 17, 2011
Messages
14,271
I have used same program as listed below for 16x4 LCD display and it is working perfectly but it is not working with 16x1 LCD display.
  1. Do the 2 LCDs understand the same commands (compatible LCD controllers)? Give us links to the datsheets of the 2 LCDs.
  2. Are the 2 LCDs connected correctly to the processor? Does the timing of the signals conform to the datasheet?
  3. What means "is not working"? Which part of the program works, which doesn't work?
  4. Where it "doesn't work": What is the expected behavior, what happens instead?
 
Top