欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
DS1302時(shí)鐘 DH11溫濕度 帶到計(jì)時(shí)顯示
[打印本頁]
作者:
jubaolun
時(shí)間:
2017-6-5 20:05
標(biāo)題:
DS1302時(shí)鐘 DH11溫濕度 帶到計(jì)時(shí)顯示
由于公司電腦,不能圖片與視頻
#include <reg52.h>
#include"1602.h"
#include"delay.h"
#include "ds1302.h"
#include "key.h"
#include"dh11.h"
#include <intrins.h>
extern uchar S1num,flag,second,minute,hour,week,day,month,year;//秒、分、時(shí)、星期、日、月、年
extern bit keyflag;
/////////////////////////////////////////////////////
extern uchar RHL,RHH,CL,CH;
extern uint m,n;
/////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
uchar code line1_data[] = {"00:00:00 "}; //定義第2行顯示的字符
/*****************讀出秒的十進(jìn)制數(shù)***************************/
uchar readsecond()
{
uchar dat;
dat=read_1302add(0x81);
second=((dat&0x70)>>4)*10+(dat&0x0f);
return second;
}
/*****************讀出分的十進(jìn)制數(shù)***************************/
uchar readminute()
{
uchar dat;
dat=read_1302add(0x83);
minute=((dat&0x70)>>4)*10+(dat&0x0f);
return minute;
}
/*****************讀出小時(shí)的十進(jìn)制數(shù)***************************/
uchar readhour()
{
uchar dat;
dat=read_1302add(0x85);
hour=((dat&0x70)>>4)*10+(dat&0x0f);
return hour;
}
/*****************讀出天的十進(jìn)制數(shù)***************************/
uchar readday()
{
uchar dat;
dat=read_1302add(0x87);
day=((dat&0x70)>>4)*10+(dat&0x0f);
return day;
}
/*****************讀出月的十進(jìn)制數(shù)***************************/
uchar readmonth()
{
uchar dat;
dat=read_1302add(0x89);
month=((dat&0x70)>>4)*10+(dat&0x0f);
return month;
}
uchar readyear()
{
uchar dat;
dat=read_1302add(0x8d);
year=((dat&0xf0)>>4)*10+(dat&0x0f);
return year;
}
/************************讀出所有時(shí)間**********************/
void readtime()
{
readsecond();
readminute();
readhour();
}
void Timer0Init(void) //50毫秒@12.000MHz
{
TMOD |= 0x01; //設(shè)置定時(shí)器模式
TL0 = 0xB0; //設(shè)置定時(shí)初值
TH0 = 0x3C; //設(shè)置定時(shí)初值
// TR0 = 1; //定時(shí)器0開始計(jì)時(shí)
EA=1;
ET0=1;
}
void main()
{
uchar i;
Timer0Init();
LCD_Init(); //初始化液晶
Delay_ms(20); //延時(shí)有助于穩(wěn)定
LCD_Clear(); //清屏
init_1302();
LCD_Write_Com(0x40|0x80); //設(shè)置顯示位置為第2行第0列
i = 0;
while(line1_data[i] != '\0') //在第2行0~3列顯示"****"
{
LCD_Write_Data(line1_data[i]); //顯示第2行字符
i++; //指向下一字符
}
Delay_ms(1000);
while(1)
{
keyscan();
if(keyflag==0)
{
readtime(); //讀取時(shí),分,秒
write_second(); //寫秒
write_minute(); //寫分
write_hour(); //寫時(shí)
}
Delay_ms(100);
receive();
}
}
void timer0() interrupt 0 //12M/50ms
{
uint num;
TL0 = 0xB0; //設(shè)置定時(shí)初值
TH0 = 0x3C; //設(shè)置定時(shí)初值
num++;
if(num==20) //大致1s
{
num=0;
second1--;
if(second1<0) //秒到60,分鐘加1
{
second1=59;
minute1-1;
if(minute1<0)//分鐘到60,小時(shí)加1
{
minute1=59;
hour1-1;
}
}
}
if(((second1==0)&minute1==0)&hour1==0)
{
TR1=0;
BEEP();
}
}
復(fù)制代碼
作者:
周工58
時(shí)間:
2022-12-7 21:42
好資料,謝謝,參考考下。
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1