ADC端口为P0.1。工作频率为11.0592,把计算结果发到串口。收到的全是00。还请高手指点!
#include <STC8.h>
#include<intrins.h>
sbit led=P6^1;
unsigned int a,b,c,i;
void main()
{
P0M0=0x00;
P0M1=0xff;
TMOD=0x20;
TL1=0xfd;
TH1=0xfd;
PCON=0x30;
SCON=0x40;
AUXR=0x00;
TR1=1;
ADCCFG=0x0f;
ADC_CONTR=0x89;
while(1)
{
ADC_CONTR|=0x40;
_nop_();
_nop_();
while(!(ADC_CONTR & 0x20));
ADC_CONTR&=~0x20;
a=(ADC_RES*16/4096)*3;
SBUF=a;
while(TI==0);
TI=0;
for(i=0;i<65535;i++);
}
}
|