#include<iom128v.h>
#include<macros.h>
#define LCD_data PORTA;
#define rs_h PORTB |= (1<<PA0);
#define rs_l P0RTB &= ~(1<<PA0);
#define rw_h PORTB |= (1<<PA1);
#define rw_l P0RTB &= ~(1<<PA1);
#define en_h PORTB |= (1<<PA2);
#define en_l P0RTB &= ~(1<<PA2);
char table[]={"今天是校运会"};
void delay(int ms)
{
int a, b;
for (a = 0; a<ms; a++)
for (b = 0; b<1141; b++);
}
void wr_com(unsigned char date)
{
rs_l;
rw_l;
PORTB=date;
en_l;
delay(10);
en_h;
delay(10);
en_l;
}
void wr_dat(unsigned char date)
{
rs_h;
rw_l;
PORTB=date;
en_l;
delay(10);
en_h;
delay(10);
}
void init()
{
DDRA=0XFF;
DDRB=0XFF;
PORTA=0XFF;
PORTB=0XFF;
wr_com(0x01);
wr_com(0x0c);
wr_com(0x30);
}
void main()
{
char i;
init();
write_com(0x80);
for(i=0;i<12;i++)
{
wr_dat(table[i]);
delay(20);
}
while(1);
}