#include
#include
#define uint unsigned int
#define uchar unsigned char
#define psbset DDRB |= (1<<4)
#define psbset PORTB |= (1<<4)
#define psbclr PORTB &=~(1<<4)
#define rsout DDRB |= (1<<5)
#define rsset PORTB |=(1<<5)
#define rsclr PORTB &=~(1<<5)
#define rwout DDRB |= (1<<6)
#define rwset PORTB |= (1<<6)
#define rwclr PORTB &= ~(1<<6)
#define enout DDRB |= (1<<7)
#define enset PORTB |= (1<<7)
#define enclr PORTB &= ~(1<<7)
unsigned char table1[]=” 2012年02月04日”;
unsigned char table2[]=”星期六 温度 8℃”;
unsigned char table3[]=” 00: 00: 00″;
unsigned char table4[]=” 科嵌电子创造”;
uint num=50,fen=9,shi=8,ri=04,yue=02;;
void mcu_init(void);
void timer1_init(void)
{
}
void Delayus(uint US)
{
}
void Delayms(uint MS)
{
}
void write_12864com(uchar com)
{
rwclr;
rsclr;
Delayus(500);
PORTA=com;
enset;
Delayus(1000);
enclr;
Delayus(1000);
}
void write_12864dat(uchar dat)
{
rwclr;
rsset;
Delayus(500);
PORTA=dat;
enset;
Delayus(1000);
enclr;
Delayus(1000);
}
void init12864lcd(void)
{
Delayms(500);
write_12864com(0x30);
Delayus(500);
write_12864com(0x30);
Delayus(500);
write_12864com(0x0f);
Delayus(500);
write_12864com(0x01);
Delayms(25);
write_12864com(0x06);
Delayus(2500);
write_12864com(0x0c);
Delayus(500);
}
void display(void)
{
uchar i;
write_12864com(0x80);
for(i=0;i<16;i++)
{
write_12864dat(table1[i]);
Delayms(10);
}
}
void display1(void)
{
uchar i;
write_12864com(0x90);
for(i=0;i<16;i++)
{
write_12864dat(table2[i]);
Delayms(10);
}
}
void display2(void)
{
uchar i;
write_12864com(0x88);
for(i=0;i<12;i++)
{
write_12864dat(table3[i]);
Delayms(10);
}
}
void display3(void)
{
uchar i;
write_12864com(0x98);
for(i=0;i<14;i++)
{
write_12864dat(table4[i]);
Delayms(10);
}
}
void write_sfm(uchar add,uchar date)
{
uchar shi,ge;
shi=date/10;
ge=date;
write_12864com(add);
write_12864dat(0x30+shi);
write_12864dat(0x30+ge);
}
void main(void)
{
init12864lcd();
timer1_init();
SEI();
display();
display1();
display2();
display3();
while(1)
{
write_sfm(0x8B,fen);
write_sfm(0x89,shi);
write_sfm(0x86,ri);
write_sfm(0x84,yue);
}
}
void mcu_init(void)
{
}
#pragma interrupt_handler timer1_ovf_isr:15
void timer1_ovf_isr(void)
{
TCNT1H = 0xE1;
if(num==60)
{
fen++;
if(fen==60)
{
shi++;
if(shi==24)
{
ri++;
if(ri==32)
{
}
}
}
}
}
声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qiche/adas/262334.html