#include "SH88F516.h"
int get_adc(char ch)
{
int i,adc;
ADCON = 0x80; //允许ADC模块
ADT = 0xee; //DC时钟为系统时钟的32分频
ADCH = ch; //选择AD输入通道
ADCON |= ch; //选择CH1通道
for(i=0;i<250;i++);
ADCON |= 0x01; //开始ADC转换
while(ADCON&0x01);
adc = ADDH;
adc = adc<<2 + ADDL;
return adc;
}//我是那么用的。 |
|