#include <SH79F083.H>
#include <INTRINS.H>
#include <define.h>
bit flag=0;
//unsigned char code eeprom[2048] _at_ 0x3000;
void init(void)//初始化寄存器
{
EA=0;
EA=1;
}
void initadc(void)
{
ADT = Bin(11100000); //T(ad) = 32*(1/16M) = 2us
//ADCH = Bin(00000001); //AN0,AN1,AN2
//ADCON = Bin(10000000); //ADC enable,ref为vdd
//ADCON |= Bin(00000001); //start converse from AN0~
ADCH = Bin(00000010); //AN0,AN1,AN2
ADCON = Bin(10010000); //ADC enable,ref为p1.0
ADCON |= Bin(00000010); //start converse from AN1~
IEN0 |=Bin(01000000);//enable adc interuppt
}
void delay(int n)
{
int i=0,m=0,x=0;
for(m=0;m<n;m++)
{
for(i=0;i<100;i++)
{
x=0;
}
}
}
void main()
{
//// unsigned char i,m;
unsigned int adc;
init();
initadc();
while(1)
{
if(flag==1)
{
adc=ADDH;
delay(10);
adc=ADDL;
delay(10);
flag=0;
ADCON|=0X1;
}
}
} |