#include
#define uchar unsigned char
#pragma data:code
const uchar string1[]="AVR 单片机12684 ";
void RDBZ()
{
PORTD&=~BIT(4);
PORTD|=BIT(5);
PORTD&=~BIT(6);
DDRA=0XFF;
PORTA=0XFF;
PORTD|=BIT(6);
DDRA=0X00;
PORTA=0XFF;
while(PINA&0x80);
}
void write_cmd(uchar cmd,uchar buzy)
{
if(buzy)
RDBZ();
DDRA=0XFF;
PORTD&=(~BIT(5)&~BIT(4));
PORTD|=BIT(6);
PORTA=cmd;
PORTD&=~BIT(6);
}
void delay()
{
uchar i;
for(i=0;i<5000;i++);
}
void init()
{
delay();
DDRD=0XFF;
PORTD|=BIT(3);
PORTD&=~BIT(3);
PORTD|=BIT(3);
write_cmd(0x30,0);
delay();
write_cmd(0x30,0);
delay();
write_cmd(0x0C,1);
delay();
write_cmd(0x01,1);
delay();
delay();
write_cmd(0X06,1);
delay();
write_cmd(0X0F,1);
delay();
// write_cmd(0X03,1);
delay();
//write_cmd(0X7A,1);
delay();
}
void write_dat(uchar dat)
{
RDBZ();
DDRA=0XFF;
PORTD&=~BIT(5);
PORTD|=BIT(6)|BIT(4);
PORTA=dat;
PORTD&=~BIT(6);
}
void main()
{
uchar j;
init();
{
write_cmd(0x90,1);
for(j=0;j<16;j++)
{
write_dat(string1[j]);
}
}
while(1);
}