#include <iom16v.h>
#include <macros.h>
#define uchar unsigned char
#define uint unsigned int
//#pragma data:code
//const uchar table[]="I LOVE WOMAN";
void delay(uint ms)
{
uint i,j;
for(i=0;i<ms;i++)
{
for(j=0;j<1141;j++);
}
}
void write_com(uchar com)
{
delay(16);
PORTD&=~BIT(4);
PORTD&=~BIT(5);
PORTB&=0X0F;
PORTB|=com&0XF0;
PORTD|=BIT(6);
delay(1);
PORTD&=~BIT(6);
com=com<<4;
PORTD&=~BIT(4);
PORTD&=~BIT(5);
PORTB&=0X0F;
PORTB|=com&0XF0;
PORTD|=BIT(6);
delay(1);
PORTD&=~BIT(6);
}
void write_dat(uchar dat)
{
delay(16);
PORTD|=BIT(4);
PORTD&=~BIT(5);
PORTB&=0X0F;
PORTB|=dat&0XF0;
PORTD|=BIT(6);
delay(1);
PORTD&=~BIT(6);
dat=dat<<4;
PORTD|=BIT(4);
PORTD&=~BIT(5);
PORTB&=0X0F;
PORTB|=dat&0XF0;
PORTD|=BIT(6);
delay(1);
PORTD&=~BIT(6);
}
void main()
{
//uchar i;
DDRB=0X0F;
DDRD|=BIT(4)|BIT(5)|BIT(6);
PORTD&=~BIT(6);
PORTD|=BIT(6);
delay(5);
PORTD&=~BIT(6);
delay(40);
write_com(0X38);
delay(3);
write_com(0X38);
delay(3);
write_com(0X38);
delay(3);
write_com(0X28);
delay(3);
write_com(0X08);
delay(3);
write_com(0X01);
delay(5);
write_com(0X06);
delay(5);
write_com(0X0C);
delay(3);
write_dat(0X07);
delay(3);
write_com(0X0F);
delay(5); |