#include <reg51.h>
#include <INTRINS.H>
#include <STDIO.H>
// define P1.0 to check STATUS.
sbit STATUS = P1^0;
unsigned char xdata CTRL _at_ 0x2FFF;
unsigned char xdata ADSEL _at_ 0x4FFF;
unsigned char hByte;
unsigned char lByte;
void adc_Convert (void)
{ // Start a conversion with A0 and A/$C$ low.
// The convesion takes place on rising CE edge.
CTRL = 0x00;
ADSEL = 0x00;
// Wait until we have completed a conversion .
while(STATUS==1);
// Set R/$C$ with A0 low and read the low byte.
CTRL = 0x02;
hByte = ADSEL;
// Set R/$C$ with A0 high and read the high.
CTRL = 0x03;
lByte = ADSEL;
}
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载