<code class="language-c">#include<reg52.h> #define uint unsigned int #define uchar unsigned char uchar code table[]={ 0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f,0x77,0x7c, 0x39,0x5e,0x79,0x71}; uint tent,sec; bit write=0; sbit sda=P1^2; sbit scl=P1^7; sbit dula=P2^6; sbit wela=P2^7; void delay() {;;} void delay1ms(uint z) { uint x,y; for(x=0;x<z;x++) for(y="0;y<110;y++);" } void start() { sda="1;" delay(); scl="1;" stop() response() uint i; while((sda="=1)&&(i<250))" i++; init() write_byte(uchar date) uchar temp,i; temp="date;" for(i="0;i<8;i++)" read_byte() k,i; k="(k<<1)|sda;" dealy(); return k; write_24c02(uchar adress,uchar start(); write_byte(0xa0); response(); write_byte(adress); write_byte(date); stop(); read_add(uchar adress) date; write_byte(0xa1); date="read_byte();" display(uchar shi,uchar ge) dula="1;" p0="table[shi];" wela="1;" delay1ms(5); main() init(); sec="read_add(2);" if(sec>100) sec=0; TMOD=0x01; TH0=(65535-50000)/256; TL0=(65535-50000)%256; EA=1; ET0=1; TR0=1; while(1) { display(sec/10,sec%10); if(write==1) { write=0; write_24c02(2,sec); } } } void qwe()interrupt 1 { TH0=(65535-50000)/256; TL0=(65535-50000)%256; tent++; if(tent=20) { tent=0; sec++; write=1; if(sec==100) sec=0; } } </z;x++)></reg52.h></code>
[修改于 8年6个月前 - 2016/06/16 12:22:19]
时段 | 个数 |
---|---|
{{f.startingTime}}点 - {{f.endTime}}点 | {{f.fileCount}} |