微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 128*64代码进化版显示时,分,秒

128*64代码进化版显示时,分,秒

时间:11-30 来源:互联网 点击:
显示结果:

芯片晶振11.0592

#include

#define uchar unsigned char
#define uint unsigned int

#define dataport P0 //数据口
sbit CS1=P2^4; //左显引脚
sbit CS2=P2^3; //右显引脚
sbit RST=P2^2; //复位引脚
sbit rs=P2^7; //数据或指令寄存器引脚
sbit rw=P2^6; //读或写操作引脚
sbit en=P2^5; //读写时能引脚
void delay(unsigned long v); //延时
void wcode(uchar c,uchar csl,uchar csr); //写指令
void wdata(uchar c,uchar csl,uchar csr); //写数据
void set_startline(uchar i); //设置起始行
void set_xy(uchar x,uchar y); //设置X,Y方向
void dison_off(uchar k); //显示器开或关
void reset();//复位
void lcd_init(); //显示器初始化
void lw(uchar x,uchar y,uchar dd); //将数据写入左右半屏
void display_hz(uchar xx,uchar yy,uchar n,uchar fb); //显示汉字函数
uchar code hz[]; //汉字字摸
uchar code asc[];//数字字摸
uchar hour1,hour0;
uchar minute1,minute0;
uchar sec1,sec0;
uchar hour=0,minute=0,sec=0;
uchar osc=0;

void Timer0(void)//设定定时器0 50ms
{
TMOD = 0x01;
TH0 = 0x3C;
TL0 = 0x0B0;
EA = 1;
ET0 = 1;
TR0 = 1;
}
void time0init()interrupt 1 //定时器中断执行,时,分,秒计算
{
TR0=0;
osc++;
if(osc==20){sec++;osc=0;}
if(sec==60){minute++; sec=0;}
if(minute==60){hour++;minute=0;}
if(hour==24){hour=0;}
hour1=hour/10;
hour0=hour%10;
minute1=minute/10;
minute0=minute%10;
sec1=sec/10;
sec0=sec%10;
TH0=0x3c;
TL0=0x0B0;
EA=1;
ET0=1;
TF0=0;
TR0=1;
}

#include "12864hh.h"

void main(void)
{
lcd_init();
delay(1000);
Timer0();
while(1)
{

display_hz(2,0,0,0);
display_hz(4,0,1,0);
display_hz(6,0,2,0);
display_hz(8,0,3,0);
display_hz(10,0,4,0);
display_hz(0,4,5,0);
display_hz(6,4,6,0);
display_hz(12,4,7,0);
display_asc(2,4,hour1,0);
display_asc(3,4,hour0,0);
display_asc(8,4,minute1,0);
display_asc(9,4,minute0,0);
display_asc(14,4,sec1,0);
display_asc(15,4,sec0,0);

}
delay(60000);
}
//-------------------------中文字字模------------------------------
uchar code hz[]={
0x20,0x04,0x20,0x04,0x22,0x42,0x22,0x82,0xFE,0x7F,0x21,0x01,0x21,0x01,0x20,0x10,
0x20,0x10,0xFF,0x08,0x20,0x07,0x22,0x1A,0xAC,0x21,0x20,0x40,0x20,0xF0,0x00,0x00,/*"我",0*/

0x00,0x40,0x40,0x20,0xB2,0xA0,0x96,0x90,0x9A,0x4C,0x92,0x47,0xF6,0x2A,0x9A,0x2A,
0x93,0x12,0x91,0x1A,0x99,0x26,0x97,0x22,0x91,0x40,0x90,0xC0,0x30,0x40,0x00,0x00,/*"爱",1*/

0x00,0x08,0x00,0x08,0xF8,0x0B,0x28,0x09,0x29,0x09,0x2E,0x09,0x2A,0x09,0xF8,0xFF,
0x28,0x09,0x2C,0x09,0x2B,0x09,0x2A,0x09,0xF8,0x0B,0x00,0x08,0x00,0x08,0x00,0x00,/*"单",2*/

0x00,0x80,0x00,0x40,0x00,0x30,0xFE,0x0F,0x10,0x01,0x10,0x01,0x10,0x01,0x10,0x01,
0x10,0x01,0x1F,0x01,0x10,0x01,0x10,0xFF,0x10,0x00,0x18,0x00,0x10,0x00,0x00,0x00,/*"片",3*/

0x08,0x04,0x08,0x03,0xC8,0x00,0xFF,0xFF,0x48,0x00,0x88,0x41,0x08,0x30,0x00,0x0C,
0xFE,0x03,0x02,0x00,0x02,0x00,0x02,0x00,0xFE,0x3F,0x00,0x40,0x00,0x78,0x00,0x00, /*机",4*/

0x00,0x00,0xFC,0x07,0x44,0x04,0x44,0x04,0x44,0x04,0xFC,0x07,0x10,0x00,0x90,0x00,
0x10,0x03,0x10,0x40,0x10,0x80,0xFF,0x7F,0x10,0x00,0x10,0x00,0x10,0x00,0x00,0x00,/*"时",0*/

0x80,0x00,0x40,0x80,0x20,0x40,0x98,0x20,0x87,0x10,0x82,0x0F,0x80,0x00,0x80,0x00,
0x83,0x20,0x84,0x40,0x98,0x3F,0x30,0x00,0x60,0x00,0xC0,0x00,0x40,0x00,0x00,0x00,/*"分",1*/

0x12,0x04,0x12,0x03,0xD2,0x00,0xFE,0xFF,0x91,0x00,0x11,0x83,0xC0,0x80,0x38,0x40,
0x10,0x40,0x00,0x20,0xFF,0x23,0x00,0x10,0x08,0x08,0x10,0x04,0x60,0x03,0x00,0x00};/*"秒",2*/
//------------------------------数字字摸----------------------------------
uchar code asc[]={
0x00,0x00,0xE0,0x0F,0x10,0x10,0x08,0x20,0x08,0x20,0x10,0x10,0xE0,0x0F,0x00,0x00,/*"0",0*/

0x00,0x00,0x10,0x20,0x10,0x20,0xF8,0x3F,0x00,0x20,0x00,0x20,0x00,0x00,0x00,0x00,/*"1",1*/

0x00,0x00,0x70,0x30,0x08,0x28,0x08,0x24,0x08,0x22,0x88,0x21,0x70,0x30,0x00,0x00,/*"2",2*/

0x00,0x00,0x30,0x18,0x08,0x20,0x88,0x20,0x88,0x20,0x48,0x11,0x30,0x0E,0x00,0x00,/*"3",3*/

0x00,0x00,0x00,0x

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top