[img]file:///C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/{H$]5UNO{S70ZEF2HL7[CF0.png[/img]交谈中请勿轻信汇款、中奖信息、陌生电话,勿使用外挂软件。
深爱请继续(289933944) 09:26:49
/************************************************************
外部晶振为16m
************************************************************/
#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;
}
}
}
大师们指点一下。为什么进不了adc中断??? |