📄 floatex.c
字号:
/************************************************/
/************************************************/
#include <REG52.H>
#include <stdio.h>
#include <intrins.h>
#ifdef MONITOR51 /* Debugging with Monitor-51 needs */
char code reserve [3] _at_ 0x23; /* space for serial interrupt if */
#endif /* Stop Exection with Serial Intr. */
/* is enabled */
const char Ledbuf[18]=/*digit convert table*//* 共阴*/
{ 0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x6F,
/* 0 1 2 3 4 5 6 7 8 9 */
0x77, 0x7C, 0x39, 0x1000E, 0x79, 0x71, 0x00, 0x40 };
/* a b c d e f - */
sbit P10=P1^0;
sbit P11=P1^1;
sbit P12=P1^2;
sbit P15=P1^5;
sbit P16=P1^6;
sbit P17=P1^7;
sbit P32=P3^2;
unsigned char th,tl;
unsigned int dat,chdate[4];
void Delay(unsigned int DelayTime)
{
if (DelayTime == 0)return;
while(DelayTime != 0)
{DelayTime--; }
}
void computer(unsigned int dt)
{ unsigned char cledtim[5];
unsigned int dth,dtm,dtl;
unsigned char i,temp;
temp=0x01;
cledtim[4]=Ledbuf[dt/10000];
dth=dt%10000;
cledtim[3]=Ledbuf[dth/1000];
dtm=dth%1000;
cledtim[2]=Ledbuf[dtm/100];
cledtim[2]|=0x80;
dtl=dtm%100;
cledtim[1]=Ledbuf[dtl/10];
cledtim[0]=Ledbuf[dtl%10];
if(cledtim[4]==0x3F)
{ P0=0x00;
P2=0x10;
Delay(100);
for(i=0;i<4;i++)
{P0=cledtim[i];
P2=temp;
temp<<=1;
Delay(100);}}
else {for(i=0;i<5;i++)
{P0=cledtim[i];
P2=temp;
temp<<=1;
Delay(100);}}
}
unsigned int adcon()
{ unsigned int dc;
dc=0x0000;
dc=th;
dc<<=8;
dc|=tl;
dc/=2;
dc-=10001;
dc/=1;
return(dc);
}
void bust_int(void) interrupt 0 using 1
{
EA=0;
th=TH0;
tl=TL0;
TH0=0x00;
TL0=0x00;
IE0=0;
EA=1; //12/03
}
void main()
{ TH0=0x00;
TL0=0x00;
for(;;)
{unsigned int Had,Lad;
unsigned int Hpv,Lpv;
unsigned int ptem,adtem,vtem;
unsigned long test,tests;
Had=5000;
Lad=1000;
Hpv=185;
Lpv=65;
ptem=Hpv-Lpv;
adtem=Had-Lad;
P1=0x00;
TR0=0;
TMOD=0x09;
IT0=1;
TR0=1;
EX0=1;
EA=1;
dat=adcon();
vtem=190-Lpv;
test=vtem;
test*=adtem;
tests=Lad;
tests*=ptem;
test=test+tests;
test/=ptem;
computer(dat);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -