#include <reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit out10=P1^0;// CE =1
sbit out11=P1^1;// R/C
sbit out12=P1^2;// ad out =1
sbit out13=P1^3;// cs =0
sbit out14=P1^4;// ad out =0
sbit out15=P1^5;// ad 信号 =0转换结束
sbit out16=P1^6;// 合格信号
sbit out17=P1^7;// 超信号
sbit out24=P2^4;// 低信号
sbit out25=P2^5;// 工作命令
const float code ad2vh[]={0,0.320,0.640,0.960,1.280,1.600,1.920,2.240,2.560,2.880,
3.200,3.520,3.840,4.160,4.480,4.800};//高8位字节
const float code ad2vl[]={0,0.020,0.040,0.060,0.080,0.100,0.120,0.140,0.160,0.180,
0.200,0.220,0.240,0.260,0.280,0.300};//底8位字节
//**********数值*******
int a;
int b;
int n;
//********初始化*********//
void restart()
{
out13=0x1;
out10=0x0;//AD关闭
out12=0x1;
out14=0x0;//AD8位设置
out15=0x0;
out16=0x0;
out17=0x0;
out24=0x0;
}
//***********AD输入***************//
void adin()
{
a=P3;//底8位存入a
b=P2;//高8位存入b
b=b&0xf0;
n=a+b;//AD数据存入N
n=ad2vh[n&0xf0]+ad2vl[n&0xf0];//ad数据转换为10进制
}
//********************主程序************
void main()
{
while(1)
{
while(out25==1)
{
restart;
out13=0x0;
out10=0x1;//启动AD
while(out15==0)//等待转换
{
adin;
if(a<11&&a>9)
{
out16=0x1;
}
if(a<9)
{
out24=1;
}
if(a>11)
{
out17=0x1;
}
}
}
}
}
————————————————————————————————————————
用的是AD574,帮忙看下程序有没有错误,编译时有三个警告···
11脚的-15v可以用开关电源上的-15v直接接上么?第十脚的基准电压输入要输几V???