资源描述:
《多功能电子钟设计说明书.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、多功能电子钟设计说明书一.作品硬件原理图三、程序流程图四.程序源代码1.头文件代码#ifndef__dianz_H__#define__dianz_H__sbitSD=P1^0;//串行数据输入sbitST_CK=P1^1;//存储寄存器时钟输入sbitSH_CK=P1^2;//移位寄存器时钟输入unsignedcharcodetab[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};//列扫描unsignedcharcodedigittab[7][8]={
2、//字模取模方式阴码逆向逐列式{0x00,0x26,0x49,0x49,0x49,0x32,0x00,0x00},/*"S",0*/{0x00,0x00,0x00,0x48,0x7A,0x40,0x00,0x00},/*"i",1*/{0x00,0x78,0x08,0x08,0x78,0x08,0x78,0x00},/*"m",2*/{0x00,0xF8,0x48,0x48,0x48,0x48,0x30,0x00},/*"p",3*/{0x00,0x00,0x00,0x3E,0x40,0x20,0x00,0x00
3、},/*"l",4*/{0x00,0x38,0x54,0x54,0x54,0x58,0x00,0x00},/*"e",5*/{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},};unsignedcharoutwork[8]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};//屏显unsignedchari,j,k,num;//变量unsignedcharta,cntb;voidSer_IN(unsignedcharData)//将8位二进制输入
4、锁存器{unsignedchari;for(i=0;i<8;i++){SH_CK=0;//CLOCK_MAX=100MHzSD=Data&0x80;Data<<=1;SH_CK=1;}}voidPar_OUT(void)//将锁存器中的数值输出显示在点阵上{ST_CK=0;ST_CK=1;}voidGo_dianzhen(){{if(cnta<7){//if(cntb<8){//for(i=0;i<50;i++){for(j=0;j<8;j++){Ser_IN(tab[j]);Ser_IN(outwork[j])
5、;Par_OUT();}//endfor(j)}//endfor(i)Ser_IN(0x00);Ser_IN(0x00);Par_OUT();for(j=0;j<7;j++){outwork[j]=outwork[j+1];}outwork[7]=digittab[cnta][cntb];tb++;}//endfor(cnta)if(cntb==8){cntb=0;ta++;}}//endfor(cntb)if(cnta==7)cnta=0;}//endwhile()}#endif2..头文件代码
6、#include"reg52.h"sbitP1_3=P1^6;unsignedcharcodeTABLE[]={0x82,0x01,0x81,0x94,0x84,0xB4,0xA4,0x04,0x82,0x01,0x81,0x94,0x84,0xC4,0xB4,0x04,0x82,0x01,0x81,0xF4,0xD4,0xB4,0xA4,0x94,0xE2,0x01,0xE1,0xD4,0xB4,0xC4,0xB4,0x04,0x82,0x01,0x81,0x94,0x84,0xB4,0xA4,0x04,0x8
7、2,0x01,0x81,0x94,0x84,0xC4,0xB4,0x04,0x82,0x01,0x81,0xF4,0xD4,0xB4,0xA4,0x94,0xE2,0x01,0xE1,0xD4,0xB4,0xC4,0xB4,0x04,0};unsignedintcodeTABLE1[]={64260,64400,64524,64580,64684,64777,64820,64898,64968,65030,65058,65110,65157,65178,65217};unsignedcharth0_temp,tl
8、0_temp;voidSING(unsignedcharhi);voidDELAY(unsignedcharlo);voidmainsing(){unsignedchari,hi,lo,coute;TMOD=0X01;ET0=1;EA=1;TR0=1;P1_3=1;coute=0;while(TABLE[coute]!=0){i=TABLE[coute];coute++;