找回密码
 注册会员
更新自动建库工具PCB Footprint Expert 2024.04 Pro / Library Expert 破解版

求救大神们啊,这个程序哪不对啊,时钟程序

[复制链接]
admin 发表于 2012-9-2 13:21:04 | 显示全部楼层 |阅读模式

本文包含原理图、PCB、源代码、封装库、中英文PDF等资源

您需要 登录 才可以下载或查看,没有账号?注册会员

×
#include <reg52.h>
#include <absacc.h>
#define LCD_WR_COM XBYTE[0x8000]
#define LCD_RD_BF XBYTE[0x8001]
#define LCD_WR_RAM XBYTE[0x8002]
#define LCD_RD_RAM XBYTE[0x8003]
sbit led1 = P1^3;
sbit L=P1^2;
unsigned char x,y;
unsigned char code LCD_DATA[16] =
{
'0','1','2','3','4','5','6','7','8','9','a','v','c','e','e','-'
};
unsigned char shi,fen,miao;
void msDelay(unsigned int t)
{
unsigned int i,j;

for(i=0;i<t;i++)
for(j=0;j<111;j++); //111
}
void wait(void)
{
while((LCD_RD_BF & 0x80) == 0x80);
}
void init_lcd(void)
{
LCD_WR_COM = 0x3c; // Set Function, 2 line, 8 bit data, 5x8
wait();
LCD_WR_COM = 0x0f; // Set Switch, display ON
wait();
LCD_WR_COM = 0x01; // Clear display
wait();
LCD_WR_COM = 0x06; // Set Mode,
wait();
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
EA=1;
ET0=1;
TR0=1;
}
void write_data(unsigned char a)
{
LCD_WR_RAM = a;
wait();
}
void display(unsigned char temp, unsigned char s)
{

x=s/10;
y=s%10;
LCD_WR_COM = temp + 0x80;
write_data(LCD_DATA[x]);
msDelay(1);
LCD_WR_COM=x+0x01+0x80;
write_data(LCD_DATA[y]);

}
void timer0(void)interrupt 1
{
unsigned int aa=0;

TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
aa++;
if(aa==20)
{
aa=0;
miao++;
if(miao==59)
{
miao=0;
fen++;
if(fen==59)
{
fen=0;
shi++;
if(shi==23)
{
shi=0;
}

display(0x00,shi);
}
display(0x03,fen);
}
display(0x06,miao);
}
}
void main()
{
led1=0;
init_lcd();
}
*滑块验证:
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

QQ|手机版|MCU资讯论坛 ( 京ICP备18035221号-2 )|网站地图

GMT+8, 2024-11-25 00:52 , Processed in 0.066500 second(s), 10 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表