|
- #include<reg52.h>
- #include<absacc.h>
- #define uchar unsigned char
- #define uint unsigned int
- #define ADC0809 XBYTE[0x7ff8] /* 定义ADC0809 端口地址 */
- #define LED P1
- sbit EOC=P3^0;
- //sbit cs=P3^1;
- sbit start=P3^2;
- sbit oe=P3^3;
- sbit rs=P2^2;
- sbit e=P2^4;
- sbit lamp=P2^5;
- sbit ale=P2^0;
- void delayms(uint ms);
- void main(void)
- {
- uchar temp;
- delayms(20);
- start=1;
- ale=0;
- delayms(20);
- start=0;//低脉冲启动
- ale=1;//高脉冲开始转换
- lamp=0;
- delayms(5);
- //delayms(1);
- while(EOC==0);
- oe=1;
- delayms(10);
- lamp=1;
- oe=0;
- temp=ADC0809;
- LED=temp; //采样结果输出到LED
- delayms(10);
- while(1);
- }
- void delayms(uint ms)
- // 延时子程序
- {
- uchar i,j;
- while(ms--)
- {
- for(i = 0; i < 120; i++)
- for(j=0;j<110;j++);
- }
- }
复制代码 启动后不管IN0(模拟源)接电源还是地还是什么,输出8脚全是高电平,求解答,附件有图片还有DSN文件
|
|