#include
#include
#include
#define uchar unsigned char
#define uint unsigned int
#define rs 0
#define rw 1
#define en 2
const uchar table[]={"I love u!"};
void write_com(uchar com)
{
DDRC|=(1< PORTC&=~(1<// lcdrs=0;//写命令
DDRA=0xff;
PORTA=com;
delay_nms(5);
DDRC|=(1<PORTC|=(1<delay_nms(5);
PORTC&=~(1</*
P0=com;
delay(5);
lcden=1;
delay(5);
lcden=0;
*/
}
void write_data(uchar jj)
{
//lcdrs=1;//写数
DDRC|=(1< PORTC|=(1<
//P0=jj;
DDRA=0xff;
PORTA=jj;
//delay(5);
delay_nms(5);
//lcden=1;//高脉冲激昂数据读走
DDRC|=(1< PORTC|=(1<// delay(5);
delay_nms(5);
//lcden=0;
PORTC&=~(1<
}
void display(void )
{
write_com(0x80);
write_data(table[0]);
write_com(0x81);
write_data(table[1]); //时
write_com(0x82);
write_data(table[2]); //:
write_com(0x83);
write_data(table[3]); //分
write_com(0x84);
write_data(table[4]);
write_com(0x85);
write_data(table[5]);//:
write_com(0x86);
write_data(table[6]); //秒
write_com(0x87);
write_data(table[7]);
}
void init(void)
{
//lcdrw=0;
DDRC|=(1< PORTC&=~(1<
//lcden=0;
DDRC|=(1< PORTC&=~(1< write_com(0x38);//显示开关及光标设置
write_com(0x0f);// write_com(0x0f);打开光标闪烁
write_com(0x06);//光标指针自动加一
write_com(0x01); //显示清屏数据指针清零
write_com(0x80); //数据指针初始化
// write_com(0x80);//数据指针自动初始化
}
int main(void)
{
DDRE|=(1<<2);
PORTE&=~(1<<2);
display();
while(1)
{
}
}
阅读(973) | 评论(0) | 转发(0) |