多功能数字钟的设计报告文档格式.docx
- 文档编号:22711585
- 上传时间:2023-02-05
- 格式:DOCX
- 页数:61
- 大小:126.02KB
多功能数字钟的设计报告文档格式.docx
《多功能数字钟的设计报告文档格式.docx》由会员分享,可在线阅读,更多相关《多功能数字钟的设计报告文档格式.docx(61页珍藏版)》请在冰豆网上搜索。
然后把秒、分、时计数器分成十位和个位放到8个数码管的显示缓冲区,通过数码管显示出来。
显示格式为小时十位、小时个位---分十位、分个位---秒十位、秒个位。
在处理过程中加上了按键判断程序,能对按键处理,通过键盘输入,设置当前时间存入S-3530A,然后从S-3530A读取实时时间并显示在七段码LED显示上,键盘和LED显示通过键盘专用芯片HD7279A进行控制,7279A也是I2C总线接口的芯片,系统中采用并行口线模拟I2C实现C8051F020和HD7279A的通信,用硬件实现S-3530A和HD7279A的连接。
D是时钟时间的设定,E是日历的设定,F是闹钟时间设定,分别使其输入值显示在液晶屏上,然后当时钟值与闹钟值相等时,LED灯会闪烁十次以示提醒。
1.主程序流程如图所示:
2.时间设定程序流程如图所示:
3.闹铃设定流程图如图所示:
源程序清单:
I2C.c
#include<
c8051f020.h>
//SFRdeclarations
//------------------------------------------------------------------------------------
//GlobalCONSTANTS
#defineWRITE0x00//SMBusWRITEcommand
#defineREAD0x01//SMBusREADcommand
//Deviceaddresses(7bits,lsbisadon'
tcare)
#defineCLOCK3530_ADDRESS_RESET0x60//1ack
#defineCLOCK3530_ADDRESS_STATUS0x62//2ack
#defineCLOCK3530_ADDRESS_DATEHOUR0x64//8ackyearmonthdayweekhourminutesecond
#defineCLOCK3530_ADDRESS_HOUR0x66//4ackhourminutesecond
#defineCLOCK3530_ADDRESS_INT10x68//3ack
#defineCLOCK3530_ADDRESS_INT20x6A//3ack
externcharsec,min,hou,day,mon;
externintyea;
externcharalarmclock[6];
union
{
unsignedcharClockString[7];
structRealClock
{
unsignedcharYear,Month,Day,Week,Hour,Minute,Second;
}RT;
}RealTime;
//SMBusstates:
//MT=MasterTransmitter
//MR=MasterReceiver
#defineSMB_BUS_ERROR0x00//(allmodes)BUSERROR
#defineSMB_START0x08//(MT&
MR)STARTtransmitted
#defineSMB_RP_START0x10//(MT&
MR)repeatedSTART
#defineSMB_MTADDACK0x18//(MT)Slaveaddress+Wtransmitted;
//ACKreceived
#defineSMB_MTADDNACK0x20//(MT)Slaveaddress+Wtransmitted;
//NACKreceived
#defineSMB_MTDBACK0x28//(MT)databytetransmitted;
ACKrec'
vd
#defineSMB_MTDBNACK0x30//(MT)databytetransmitted;
NACKrec'
#defineSMB_MTARBLOST0x38//(MT)arbitrationlost
#defineSMB_MRADDACK0x40//(MR)Slaveaddress+Rtransmitted;
#defineSMB_MRADDNACK0x48//(MR)Slaveaddress+Rtransmitted;
#defineSMB_MRDBACK0x50//(MR)databyterec'
vd;
ACKtransmitted
#defineSMB_MRDBNACK0x58//(MR)databyterec'
NACKtransmitted
//-----------------------------------------------------------------------------------
//GlobalVARIABLES
charCOMMAND;
//Holdstheslaveaddress+R/WbitforuseintheSMBusISR.
unsignedchar*I2CDataBuff;
charBYTE_NUMBER;
//UsedbyISRtocheckwhatdatahasjustbeen
//sent-Highaddressbyte,Lowbyte,ordatabyte
unsignedcharHIGH_ADD,LOW_ADD;
//High&
LowbyteforEEPROMmemoryaddress
bitSM_BUSY;
//Thisbitissetwhenasendorreceive
//isstarted.Itisclearedbythe
//ISRwhentheoperationisfinished.
//FunctionPROTOTYPES
voidSMBus_ISR(void);
//MAINRoutine
//
//MainroutineconfiguresthecrossbarandSMBus,andtests
//theSMBusinterfacebetweenthethreeEEPROMs
voidResetRealClock(void)
while(SM_BUSY);
//WaitforSMBustobefree.
SM_BUSY=1;
//OccupySMBus(settobusy)
SMB0CN=0x44;
//SMBusenabled,ACKonacknowledgecycle
BYTE_NUMBER=0;
//2addressbytes.
COMMAND=(CLOCK3530_ADDRESS_RESET|READ);
//Chipselect+READ
STA=1;
//Starttransfer
//Waitfortransfertofinish
}
//======================写S-3530A内部实时数据寄存器程序=====================
//功能:
将设定年、月、日、星期、时、分、秒数据写入S-3530A|
//入口:
发送数据放在年、月、日、星期、时、分、秒各寄存器|
//出口:
NONE|
//==========================================================================
voidSetRealClock(void)
BYTE_NUMBER=7;
COMMAND=(CLOCK3530_ADDRESS_DATEHOUR|WRITE);
//Chipselect+WRITE
I2CDataBuff=&
RealTime.ClockString[0];
//Datatobewriten
//==================读S-3530A实时数据寄存器子程序===========================
从S-3530A读入当前时间数据|
接收数据放在年、月、日、星期、时、分、秒各寄存器|
voidGetRealClock(void)
COMMAND=(CLOCK3530_ADDRESS_DATEHOUR|READ);
//============================写状态寄存器程序==============================
读/写S-3530A状态寄存器,对S-3530A进行设置|
NONE出口:
unsignedcharGetRealClockStatus(void)
unsignedcharresult;
BYTE_NUMBER=1;
COMMAND=(CLOCK3530_ADDRESS_STATUS|READ);
result;
returnresult;
voidSetRealClockStatus(unsignedcharstatus)
COMMAND=(CLOCK3530_ADDRESS_STATUS|WRITE);
status;
#include"
INTRINS.H"
unsignedcharrevolve(unsignedcharval)
chari;
unsignedcharval1=0;
for(i=0;
i<
8;
i++)
if(val&
0x1)
val1++;
val1=_crol_(val1,1);
val=_cror_(val,1);
}
val1=_cror_(val1,1);
returnval1;
/*--文字:
课--*/
/*--宋体12;
此字体下对应的点阵为:
宽x高=16x16--*/
charcodeke[]=
0x20,0x21,0xEE,0x04,0x00,0x00,0x00,0x7E,0x4A,0x4A,0xFE,0x4A,0x4A,0x7E,0x00,0x00,
0x00,0x00,0x3F,0x10,0x08,0x21,0x11,0x09,0x05,0x03,0xFF,0x05,0x09,0x31,0x11,0x00,
};
程--*/
charcodecheng[]=
0x10,0x12,0xD2,0xFE,0x91,0x11,0x80,0xBF,0xA1,0xA1,0xA1,0xA1,0xBF,0x80,0x00,0x00,
0x04,0x03,0x00,0xFF,0x00,0x41,0x44,0x44,0x44,0x7F,0x44,0x44,0x44,0x44,0x40,0x00,
设--*/
charcodeshe[]=
0x40,0x41,0xCE,0x04,0x00,0x80,0x40,0xBE,0x82,0x82,0x82,0xBE,0xC0,0x40,0x40,0x00,
0x00,0x00,0x7F,0x20,0x90,0x80,0x40,0x43,0x2C,0x10,0x10,0x2C,0x43,0xC0,0x40,0x00,
计--*/
charcodeji[]=
0x20,0x21,0x2E,0xE4,0x00,0x00,0x20,0x20,0x20,0x20,0xFF,0x20,0x20,0x20,0x20,0x00,
0x00,0x00,0x00,0x7F,0x20,0x10,0x08,0x00,0x00,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,
时--*/
charcodeS[]=
0x00,0xFC,0x44,0x44,0x44,0xFC,0x10,0x90,0x10,0x10,0x10,0xFF,0x10,0x10,0x10,0x00,
0x00,0x07,0x04,0x04,0x04,0x07,0x00,0x00,0x03,0x40,0x80,0x7F,0x00,0x00,0x00,0x00,
分--*/
charcodeF[]=
0x80,0x40,0x20,0x98,0x87,0x82,0x80,0x80,0x83,0x84,0x98,0x30,0x60,0xC0,0x40,0x00,
0x00,0x80,0x40,0x20,0x10,0x0F,0x00,0x00,0x20,0x40,0x3F,0x00,0x00,0x00,0x00,0x00,
秒--*/
charcodeM[]=
0x12,0x12,0xD2,0xFE,0x91,0x11,0xC0,0x38,0x10,0x00,0xFF,0x00,0x08,0x10,0x60,0x00,
0x04,0x03,0x00,0xFF,0x00,0x83,0x80,0x40,0x40,0x20,0x23,0x10,0x08,0x04,0x03,0x00,
年--*/
charcodeN[]=
0x40,0x20,0x10,0x0C,0xE3,0x22,0x22,0x22,0xFE,0x22,0x22,0x22,0x22,0x02,0x00,0x00,
0x04,0x04,0x04,0x04,0x07,0x04,0x04,0x04,0xFF,0x04,0x04,0x04,0x04,0x04,0x04,0x00,
月--*/
charcodeY[]=
0x00,0x00,0x00,0x00,0x00,0xFF,0x11,0x11,0x11,0x11,0x11,0xFF,0x00,0x00,0x00,0x00,
0x00,0x40,0x20,0x10,0x0C,0x03,0x01,0x01,0x01,0x21,0x41,0x3F,0x00,0x00,0x00,0x00,
日--*/
charcodeR[]=
0x00,0x00,0x00,0xFE,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3F,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x3F,0x00,0x00,0x00,0x00,
闹--*/
charcodenao[]=
0x00,0x00,0xF9,0x12,0x90,0x92,0x96,0xFA,0x92,0x92,0x92,0x12,0x02,0xFE,0x00,0x00,
0x00,0x00,0xFF,0x00,0x1F,0x00,0x00,0x7F,0x00,0x08,0x1F,0x40,0x80,0x7F,0x00,0x00,
钟--*/
charcodezhong[]=
0x40,0x30,0x2C,0xEB,0x28,0x28,0x00,0xF8,0x08,0x08,0xFF,0x08,0x08,0xF8,0x00,0x00,
0x01,0x01,0x01,0xFF,0x41,0x21,0x00,0x01,0x01,0x01,0xFF,0x01,0x01,0x01,0x00,0x00,
响--*/
charcodexiang[]=
0xFC,0x04,0x04,0xFC,0x00,0xF8,0x08,0xC8,0x4C,0x4B,0x4A,0x48,0xC8,0x08,0xF8,0x00,
0x07,0x02,0x02,0x07,0x00,0xFF,0x00,0x1F,0x08,0x08,0x08,0x08,0x5F,0x80,0x7F,0x00,
/*--文
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 多功能 数字 设计 报告
![提示](https://static.bdocx.com/images/bang_tan.gif)