里面的-初始时间是我定的,你可以根据你的-实际-情况修改
单片机源程序如下:
- #include<reg52.h>
- #include<intrins.h>
- typedef unsigned char uchar;
- typedef unsigned int uint;
- uchar DB8;
- uchar Wen_Zi[8][8] = {
- {0x10,0x1f,0x10,0x0f,0x0a,0x1f,0x02,0x02},
- {0x0f,0x09,0x0f,0x09,0x09,0x0f,0x09,0x13},
- {0x1f,0x11,0x11,0x1f,0x1f,0x11,0x11,0x1f},
- {0x01,0x01,0x07,0x19,0x1d,0x1b,0x19,0x03},
- {0x0a,0x11,0x00,0x1f,0x05,0x05,0x09,0x13},
- {0x04,0x04,0x0c,0x15,0x05,0x02,0x04,0x08},
- {0x1f,0x15,0x1f,0x15,0x1f,0x11,0x15,0x13},
- {0x1c,0x14,0x18,0x06,0x09,0x08,0x08,0x07},
- };
- uchar bdata DS_Shu;
- sbit DS8 = DS_Shu^7;
- sbit LEDl602_RS = P2^6;
- sbit LEDl602_WR = P2^5;
- sbit LEDl602_OE = P2^7;
- sbit DS_IO = P3^4;
- sbit DS_CE = P3^5;
- sbit DS_SCLK = P3^6;
- void Yan_Shims(uint i)
- {
- for(i=i*83;i>0;i--);
- }
- void Yan_Shius()
- {
- _nop_();
- }
- bit Mang_Lu()
- {
- bit i;
- LEDl602_OE = 0;
- LEDl602_RS = 0;
- LEDl602_WR = 1;
- LEDl602_OE = 1;
- Yan_Shius();
- DB8 = P0;
- i = (bit)(DB8&0x80);
- LEDl602_OE = 0;
- return(i);
- }
- void Zhi_Ling(uchar NUM,uchar DATA)
- {
- uchar a=0x01;
- a =_crol_(a,(NUM - 1));
- DATA = DATA +a;
- while(Mang_Lu() != 0);
- LEDl602_OE = 0;
- LEDl602_RS = 0;
- LEDl602_WR = 0;
- Yan_Shius();
- P0 = DATA;
- Yan_Shius();
- LEDl602_OE = 1;
- Yan_Shius();
- LEDl602_OE = 0;
- }
- void Xie_DATA(uchar DATA)
- {
- while(Mang_Lu() != 0);
- LEDl602_OE = 0;
- LEDl602_RS = 1;
- LEDl602_WR = 0;
- Yan_Shius();
- P0 = DATA;
- Yan_Shius();
- LEDl602_OE = 1;
- Yan_Shius();
- LEDl602_OE = 0;
- }
- void lad_rili()
- {
- uchar i,t;
- for(i=0;i<8;i++)
- {
- for(t=0;t<8;t++)
- {
- Zhi_Ling(7,i*8+t);
- Yan_Shius();
- Xie_DATA(Wen_Zi[i][t]);
- Yan_Shius();
- }
- }
- }
-
- void DS_DiZhi(uchar Di_Zhi)
- {
- uchar x;
- for(x=0;x<8;x++)
- {
- DS_IO = Di_Zhi&0x01;
- Yan_Shims(1);
- DS_SCLK = 1;
- Yan_Shims(1);
- DS_SCLK = 0;
- Di_Zhi = Di_Zhi>>1;
- }
- }
- void DS_Xie(uchar Di_Zhi,uchar Shu_Ju)
- {
- DS_SCLK = 0;
- DS_CE = 1;
- Yan_Shius();
- DS_DiZhi(Di_Zhi);
- Yan_Shius();
- DS_DiZhi(Shu_Ju);
- Yan_Shims(1);
- DS_CE = 0;
- }
- uchar DS_Du(uchar y)
- {
- uchar i,x=0;
- DS_Xie(0x8e,0x00);
- DS_SCLK = 0;
- DS_CE = 1;
- DS_DiZhi(y);
- DS_IO=1;
- for(i=0;i<8;i++)
- {
- DS_Shu=DS_Shu>>1;
- Yan_Shius();
- DS8=DS_IO;
- Yan_Shius();
- DS_IO=1;
- DS_SCLK = 1;
- Yan_Shius();
- DS_SCLK = 0;
- }
- Yan_Shius();
- DS_CE = 0;
- return DS_Shu;
- }
-
- void Clock_ChuShi()
- {
- Zhi_Ling(6,0x18);
- Yan_Shius();
- Zhi_Ling(4,0x04);
- Yan_Shius();
- Zhi_Ling(3,0x02);
- Yan_Shius();
- Zhi_Ling(1,0x00);
- Yan_Shims(10);
- lad_rili();
- Yan_Shims(3);
-
- DS_CE = 0;
- DS_SCLK = 0;
- DS_Xie(0x8e,0x00);
- DS_Xie(0x8c,0x17);
- DS_Xie(0x8a,0x02);
- DS_Xie(0x88,0x09);
- DS_Xie(0x86,0x26);
- DS_Xie(0x84,0x23);
- DS_Xie(0x82,0x35);
- DS_Xie(0x80,0x00);
- }
- void main()
- {
- Clock_ChuShi();
- while(1)
- {
- Zhi_Ling(8,0x00);
- Xie_DATA('2');
- Xie_DATA('0');
- DS_Du(0x8d);
- Xie_DATA((DS_Shu/16+48));
- Xie_DATA((DS_Shu%16+48));
- Xie_DATA(0x00);
- Zhi_Ling(5,0x04);
-
- DS_Du(0x89);
- Xie_DATA((DS_Shu/16+48));
- Xie_DATA((DS_Shu%16+48));
- Xie_DATA(0x01);
- Zhi_Ling(5,0x04);
-
- DS_Du(0x87);
- Xie_DATA((DS_Shu/16+48));
- Xie_DATA((DS_Shu%16+48));
- Xie_DATA(0x02);
- Zhi_Ling(5,0x04);
- Xie_DATA(0x06);
- DS_Du(0x8b);
- Xie_DATA((DS_Shu%16+48));
- Zhi_Ling(5,0x04);
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
实时时钟.rar
(27.56 KB, 下载次数: 5)
|