#include <iom16v.h>
#include <macros.h>
#define uchar unsigned char
#define uint unsigned int
#define lcd_RS_1 PORTD|=BIT(PD0)
#define lcd_RS_0 PORTD&=~BIT(PD0)
#define lcd_RW_1 PORTD|=BIT(PD1)
#define lcd_RW_0 PORTD&=~BIT(PD1)
#define lcd_EN_1 PORTD|=BIT(PD2)
#define lcd_EN_0 PORTD&=~BIT(PD2)
char table1[]= {" Good morning "};
char table2[]= {" wodediana! "};
void delay(int x)
{
int i;
while(x--)
{
for(i=0; i<1140; i++);
}
}
void writedata(char dat)
{
DDRD|=0x01;
lcd_RS_1;
DDRD|=0x02;
lcd_RW_0;
DDRC=0xff;
PORTC=dat;
delay(5);
DDRD|=0x04;
lcd_EN_1;
delay(1);
DDRD|=0x04;
lcd_EN_0;
}
void writecommand(char com)
{
DDRD|=0x01;
lcd_RS_0;
DDRD|=0x02;
lcd_RW_0;
DDRC=0xff;
PORTC=com;
delay(5);
DDRD|=0x04;
lcd_EN_1;
delay(1);
DDRD|=0x04;
lcd_EN_0;
}
void init()
{
DDRD|=0x04;
lcd_EN_0;
writecommand(0x38);
writecommand(0x0c);
writecommand(0x06);
writecommand(0x01);
}
void main(void)
{
int j;
init();
DDRD=0xff;
DDRC=0xff;
while(1)
{
j=0;
while(table1[j]!='\0')
{
writedata(table1[j]);
j++;
delay(10);
}
j=0;
writecommand(0x80+0x40);
while(table2[j]!='\0')
{
writedata(table2[j]);
j++;
delay(10);
}
writecommand(0x01);
delay(100);
}
}