📄 v_test.c
字号:
#include"regx52.h"
#include"absacc.h"
#define IN0 XBYTE[0x7ff8]
unsigned char dispbitcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
unsigned char dispbuf[4]; //存放数码管显示数据
unsigned int i;
unsigned int j;
unsigned char getdata; //存放读入数据
unsigned int temp;
unsigned char count;
sbit ad_busy = P3^2; //忙信号
sbit CLK = P3^5; //时钟信号
void Delay(unsigned int i)//延时
{
unsigned int j;
for(;i>0;i--)
{
for(j=0;j<125;j++)
{;}
}
}
void Display()
{
P1=dispbitcode[dispbuf[3]];
P3_0=0;
P3_1=1;
P3_3=1;
P3_4=1;
Delay(10);
P1=0x00;
P1=dispbitcode[dispbuf[2]];
P1_7=1;//小数点
P3_0=1;
P3_1=0;
P3_3=1;
P3_4=1;
Delay(10);
P1=0x00;
P1=dispbitcode[dispbuf[1]];
P3_0=1;
P3_1=1;
P3_3=0;
P3_4=1;
Delay(10);
P1=0x00;
P1=dispbitcode[dispbuf[0]];
P3_0=1;
P3_1=1;
P3_3=1;
P3_4=0;
Delay(10);
P1=0x00;
}
void t1(void) interrupt 3 using 0 //CLOCK时钟信号
{
TH1=(65536-200)/256;
TL1=(65536-200)%256;
CLK=~CLK;
}
void TimeInitial()
{
TMOD=0x10;//定时器工作在方式1
TH1=(65536-200)/256;
TL1=(65536-200)%256; //频率500HZ
EA=1;
ET1=1;
TR1=1;
}
void main()
{
unsigned char p;
unsigned char xdata *ad_adr;
TimeInitial();
ad_adr = &IN0;
while(1){
*ad_adr = 0;
p=p;
p=p;
while(ad_busy==0);
getdata = *ad_adr;
temp=getdata*1.0/255*500;
dispbuf[0] = temp%10;
dispbuf[1] = temp/10%10;
dispbuf[2] = temp/100%10;
dispbuf[3] = temp/1000;
Display();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -