#include<intrins.h>
#include"stc12c5a16s2.h"
#include"shumaguan.h"
#define FOSC 18432000L
#define BAUD 9600
sfr ADC_LOW2=0xbe;
#define uchar unsigned char
#define uint unsigned int
sbit P2_0=P2^0;
sbit fm=P3^7;
uint value;
float houdu=0.0;
void init_ADC()
{
P1ASF=0x01; //set P1.0 as analog input port
ADC_RES=0x00;
ADC_LOW2=0x00; //clear previous result
ADC_CONTR=0x88;
TMOD=0x01;
TH0=(65536-20000)/256;
TL0=(65536-20000)%256;
ET0=1;
TF0=0; //定时器0溢出标志0
TR0=1;
_nop_();
_nop_();
_nop_();
_nop_(); //ADC power on delay and start conversion
EADC=1;
EA=1; //open the interrupt
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载