void ADC_init()
{
P1ASF = 0xff;
ADC_RES = 0;
ADC_CONTR = 0xe0;
delay_ms( 5 );
AUXR1 = 0x00;
P1M0|=0x01; //开漏模式 1_0= #00000000B
P1M1|=0x01;
}
u16 ADC_process()
{
//int vol;
ADC_CONTR = 0xe8;
_nop_();
_nop_();
_nop_();
_nop_();
while ( ! ( ADC_CONTR & ADC_FLAG ) );
ADC_CONTR = 0x00;
//vol = ( ADC_RES * 100 ) / 256;
//vol *= 5;
//return vol;
return ADC_RES;
}
void ADC_init()
{
P1ASF = 0xff;
ADC_RES = 0;
ADC_CONTR = 0xe0;
delay_ms( 5 );
AUXR1 = 0x00;
P1M0|=0x01; //开漏模式 1_0= #00000000B
P1M1|=0x01;
}
u16 ADC_process()
{
//int vol;
ADC_CONTR = 0xe8;
_nop_();
_nop_();
_nop_();
_nop_();
while ( ! ( ADC_CONTR & ADC_FLAG ) );
ADC_CONTR = 0x00;
//vol = ( ADC_RES * 100 ) / 256;
//vol *= 5;
//return vol;
return ADC_RES;
}
举报