资源描述:
《中国计量学院智能仪表课程设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、中国计量学院智能仪表课程设计#include#include#include#defineucharunsignedchar#defineuintunsignedintunsignedcharc,flag1=0,flag2=0,flag3=0,aa;unsignedchartab[5]={0};unsignedintf,temp;doubletemp_555;sbitkey1=P1^5;sbitkey2=P1^6;sbitkey3=P1^7;sb
2、itD=P3^5;#defineDS12887_CLOCK_HOURXBYTE[0x7f05]//时报警#defineDS12887_CLOCK_MINUTEXBYTE[0x7f03]//分报警#defineDS12887_CL0CK_SECONDXBYTE[0x7f01]//秒报警#defineDS12887_HOURXBYTE[0x7f04]//时#defineDS12887_MINUTEXBYTE[0x7f02]//分#defineDS12887_SECONDXBYTE[0x7f00]//秒#
3、defineDS12887_WEEKXBYTE[0x7f06]//周#defineDS12887_DAYXBYTE[0x7f07]//天#defineDS12887_MONTHXBYTE[0x7f08]//月#defineDS12887_YEARXBYTE[0x7f09]//年#defineDS12887_AXBYTE[0x7f0a]#defineDS12887_BXBYTE[0x7f0b]#defineDS12887_CXBYTE[0x7f0c]#defineDS12887_DXBYTE[0x7f
4、0d]unsignedintyear_1;ucharyear=0x13;month=0x06;day=0x30;week=0x07;hour=0x18,minute=0x15,second=0x11;//用于修改时用的参变量年月日等等unsignedchartable[]={0x03,0x9f,0x25,0x0d,0x99,0x49,0x41,0x1f,0x01,0x09};voidinit_12887(void);voidread_data_time(void);voidread_data_dat
5、e(void);voiddelayms(unsignedintxms){unsignedinti,j;for(i=xms;i>0;i--)for(j=110;j>0;j--);}voidsmg(unsignedcharaddress,unsignedcharvalue){unsignedcharshi,ge;shi=value/16;ge=value%16;P1=~(address);SBUF=table[ge]&0xfe;while(!TI);TI=0;delayms(3);P1=~(addres
6、s>>1);SBUF=table[shi];while(!TI);TI=0;delayms(3);}voidinit_12887(void){DS12887_B=0x82;//更新禁止禁止中断无方波输出二进制编码二十四进制DS12887_A=0x20;c=DS12887_C;//寄存器C的初始化DS12887_YEAR=year;DS12887_MONTH=month;DS12887_DAY=day;DS12887_WEEK=week;DS12887_HOUR=hour;DS12887_MINUTE
7、=minute;DS12887_SECOND=second;DS12887_B=0x12;//芯片工作初始化结束允许中断输出}voidread_data_time(void)//用于显示的时间读取在这里可以加一个标志作为显示的特殊性有一横的!!!{hour=DS12887_HOUR;//读小时minute=DS12887_MINUTE;//读分钟second=DS12887_SECOND;//读秒数}voidread_data_date(void)//用于显示的日期读取加一个标志作为显示的特殊性用点
8、分开!!!{year=DS12887_YEAR;//读年month=DS12887_MONTH;//读月day=DS12887_DAY;//读日week=DS12887_WEEK;//读星期}voidzhongduan(){EA=1;EX0=1;//打开外部中断0PX1=1;//外部中断1定义为高优先级中断IT0=1;//外部中断1触发方式选择位INT1为跳变触发方式EX1=1;//打开外部中断1中断IT1=1;TMOD=0x05;//计数器模式计数方式116位定时器