#include<REG52.H>#include<intrins.h>#define uint unsigned int#define uchar unsigned charsfr ISP_CON=0xe7; sbit IO=P1^0;sbit CS=P2^1;sbit CLK=P2^2;sbit DAT=P2^0;uint juli,i;bit flag;void delay(uint i){ uint j,k; for(j=i;j>0;j--) for(k=0;k<114;k++);}void send(uchar add,uchar dat){ uchar i; CS=0; for(i=0;i<8;i++) { CLK=0; DAT=(bit)(add&0x80); add<<=1; CLK=1; } for(i=0;i<8;i++) { CLK=0; DAT=(bit)(dat&0x80); dat<<=1; CLK=1; } CS=1;}void dis(){ send(1,0); send(2,0); send(3,0); send(4,0); send(5,0); send(6,juli/100); send(7,(juli/10)%10); send(8,juli%10);}void launch(){ uchar i; for(i=0;i<50;i++) { IO=0; _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_(); IO=1; _nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_(); }}void init(){ TMOD=0x01; TH0=0,TL0=0; IT0=1; EA=1; send(0x09,0xff); send(0x0b,0x07); send(0x0a,0x0f); send(0x0c,0x01); send(0x0f,0x00);}void main(){ init(); dis(); while(1) { do { IO=1; TH0=0,TL0=0; EX0=1; TR0=1; launch(); delay(10); } while(flag==0); flag=0; juli=(i/2)*0.033; dis(); delay(500); ISP_CON=0x60; }}void int0() interrupt 0{ TR0=0; EX0=0; flag=1; i=(TH0*256)+TL0;} |