义隆EM78P259N AD转换求助!
时间:10-02
整理:3721RD
点击:
义隆EM78P259N AD转换,按照义隆官方给出来的例程来写,AD转换没反应呢,有谁试过AD转换啊?
AISR=0x04; //P52 IS AD INPUT 00000100
ADCON=0x8a; //10001010 VREFS=P54,CKR1/CKR0=00,ADPD=1,ADRUN=0;ADIS1/ADIS0=P52
void ADC()//AD采样
{
U8 ad_loop;
U16 ad_voit;
ADCON=0x8a; //10001010 VREFS=P54,CKR1/CKR0=00,ADPD=1,ADRUN=0;ADIS1/ADIS0=P52
ADRUN=1;
while(ADRUN)
{;}
//
li_U=0;
for(ad_loop=0;ad_loop<4;ad_loop++)//采样4次
{
ADRUN=1;
while(ADRUN)
{;}
ad_voit=ADDATA1H*256+ADDATA1L;
li_U=li_U+ad_voit;
}
li_U=li_U/4; //取平均
}
AISR=0x04; //P52 IS AD INPUT 00000100
ADCON=0x8a; //10001010 VREFS=P54,CKR1/CKR0=00,ADPD=1,ADRUN=0;ADIS1/ADIS0=P52
void ADC()//AD采样
{
U8 ad_loop;
U16 ad_voit;
ADCON=0x8a; //10001010 VREFS=P54,CKR1/CKR0=00,ADPD=1,ADRUN=0;ADIS1/ADIS0=P52
ADRUN=1;
while(ADRUN)
{;}
//
li_U=0;
for(ad_loop=0;ad_loop<4;ad_loop++)//采样4次
{
ADRUN=1;
while(ADRUN)
{;}
ad_voit=ADDATA1H*256+ADDATA1L;
li_U=li_U+ad_voit;
}
li_U=li_U/4; //取平均
}