zxf02105 发表于 2011-5-21 17:18:40

ADC0809硬件上为什么转换不出来

在硬件上做ADC0809的转换实验,为什么数据输出一直为0xff???
程序如下
#include<reg52.h>
#include<intrins.h>
#include<MT8880.h>
sbit blue=P1^0;
sbit green=P1^1;
sbit red=P1^2;
sbit yellow=P1^3;
sbit ADDA=P2^3;
sbit CLOCK=P2^4;
sbit START=P2^5;
sbit EOC=P2^6;
sbit OE=P2^7;
sbit VOICE=P3^6;
unsigned char IN0,IN1;
void delay(unsigned int d)//延时d ms   
{
    unsigned int a,b,c;
    for(c=d;c>0;c--)
      for(b=142;b>0;b--)
            for(a=2;a>0;a--);
}
void delayNOP()
{
                _nop_();_nop_();
      _nop_();_nop_();
      _nop_();_nop_();
      _nop_();_nop_();
      _nop_();_nop_();
      _nop_();_nop_();
      _nop_();_nop_();
}
void start(bit a)
{
      START=0;
      _nop_();
      _nop_();
      START=1;
      _nop_();
      ADDA=a;
      _nop_();
      _nop_();
      _nop_();
      START=0;
      delayNOP();
}
void Time()
{
      TMOD=0x10;
      TL1=255;
      TH1=255;
      EA=1;
      ET1=1;
      TR1=1;
}
void ADC0808()
{
      start(0);
                delay(1);
      while(!EOC);
      OE=1;
      IN0=P0;
      OE=0;
      if(IN0>0x1e)
                {red=0;
                VOICE=0;
                }
      else
      {red=1;
                VOICE=1;
                }
      delay(10);
      
      start(1);
                delay(1);
      while(!EOC);
      OE=1;
      IN1=P0;
      OE=0;
      if(IN1>0x99)
                {blue=0;
                VOICE=0;               
                }
      else
      {blue=1;
                VOICE=1;
                }
}
void main()
{
      Time();
      OE=0;      
      while(1)
      {
      ADC0808();
      }
}

void t1(void) interrupt 3
{
      TL1=255;
      TH1=255;
      CLOCK=~CLOCK;
}
CLK的时钟频率为500KHZ
在仿真可以实现所要的功能
为什么硬件实践时数据口P0的输出一直为高电平啊?

http://cache.amobbs.com/bbs_upload782111/files_39/ourdev_641807UBAM2V.jpg
·????????·?? (原文件名:E

liudaolunhui 发表于 2012-5-29 08:49:57

我也是转换不出来呀!!!!!!!!!!!!!!!

liudaolunhui 发表于 2012-5-31 15:30:59

    l楼主解决了吗????????
页: [1]
查看完整版本: ADC0809硬件上为什么转换不出来