欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
單片機基本電子時鐘ds1302
[打印本頁]
作者:
01rian
時間:
2024-3-23 23:10
標題:
單片機基本電子時鐘ds1302
//實驗名稱:DS1302電子時鐘
//實驗現(xiàn)象:1、將DS1302 的底層驅(qū)動代碼文件正確移植到工程中。
//2、初始化DS1302的默認啟動參數(shù)為:2024年3月2日 星期六 20時28分29秒
//3、系統(tǒng)上電后,DS1302實時時鐘從默認參數(shù)啟動運行,并將當前的時、分、秒顯示在數(shù)碼管上,時分秒之間用“-”分隔。
// 數(shù)碼管顯示:秒-分-時
//注意:(1)采用IO擴展外部內(nèi)存時,需要將電路版中的模式調(diào)為MM模式
// (2)添加比賽的底層驅(qū)動模塊時,需要檢查兩點,一是參數(shù)、函數(shù)是否完整;二是驅(qū)動函數(shù)頻率和芯片頻率是否一致,如果不一致注意延時函數(shù)倍數(shù)關(guān)系
#include<reg52.h>
#include<ds1302.h>
#include<absacc.h>
#include<smg_active.h>
unsigned char write_ds1302[8]={0x80,0x82,0x84,0x86,0x88,0x8a,0x8c,0x8e};
unsigned char read_ds1302[8]={0x81,0x83,0x85,0x87,0x89,0x8b,0x8d,0x8f};
//2024年3月2日 星期六 20時28分29秒 數(shù)碼管先顯示1分鐘2024 2024 然后03-02-20-28
unsigned char timer_ds1302[8]={0x29,0x28,0x20,0x02,0x03,0x06,0x24,0x20}; //采用BCD碼,即一個數(shù)字對應八個二進制數(shù)碼
//所以對于十進制的8421BCD來說,就是十六進制
void init_ds1302() //初始化DS1302
{
unsigned char i;
Write_Ds1302_Byte(0x8e,0x00); //在底層驅(qū)動模塊中有,
for(i=0;i<7;i++)
{
Write_Ds1302_Byte( write_ds1302[i],timer_ds1302[i]); // 依次讀取數(shù)組中內(nèi)容
}
Write_Ds1302_Byte(0x8e,0x80);
}
void read_time_ds1302()
{
unsigned char j;
for(j=0;j<7;j++)
{
timer_ds1302[j]=Read_Ds1302_Byte ( read_ds1302[j]);
}
}
void time_show()
{
SMG_single(7,SMG_nodot[timer_ds1302[0]%16]); //秒,數(shù)組中數(shù)據(jù)是十六進制,將其轉(zhuǎn)化為十進制
delay(200);
SMG_0xff();
SMG_single(6,SMG_nodot[timer_ds1302[0]/16]);
delay(200);
SMG_0xff();
SMG_single(5,0xbf); //-
delay(200);
SMG_0xff();
SMG_single(4,SMG_nodot[timer_ds1302[1]%16]); //分
delay(200);
SMG_0xff();
SMG_single(3,SMG_nodot[timer_ds1302[1]/16]);
delay(200);
SMG_0xff();
SMG_single(2,0xbf); //-
delay(200);
SMG_0xff();
SMG_single(1,SMG_nodot[timer_ds1302[2]%16]); //時
delay(200);
SMG_0xff();
SMG_single(0,SMG_nodot[timer_ds1302[2]/16]);
delay(200);
SMG_0xff();
}
void main()
{
init_ds1302();
while(1)
{
read_time_ds1302();
time_show();
}
}
*******************DS1302電子時鐘***********************
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1