Jump to content
Sign in to follow this  
Prefekt

Probelm with A/D

Recommended Posts

Hello,

I've problems with the A/D conversation. When I'am using only AN0/RA0 it works fine. But, when I'm using AN0 and AN1, the value on AN1 is correct, if AN0 has no input. If AN0 and AN1 have Input, the messuring on AN0 is ok, but the messuring on AN1 is incorrect.

 

And anoterh probelem is that i configure

trisa = 00000001b;

if I write

trisa = 00000011b; the A/D converter is not running

but I'm using AN0 and AN1 why?

 

here's the configuration:

trisa = 00000001b;

ADCon1 = 10000100b;

ADCon0 = 01000001b;

 

 

That's the code to messure AN0:

void MessureAkkuVoltage()

{

/*- Meßvorgang -*/

ADCon0 = 01000001b; /*- Select RA0 -*/

set_bit (ADCon0,2); /*- Start AD-Conversion -*/

 

while ((ADCon0 & 4) == 4)

{

nop();

}

 

/*- Wert in einer 16Bit Variable zusammenfassen -*/

iVmess = ADResH;

iVmess <<= 8;

iVmess |= ADResL;

            iVmess = iVmess * 2;  

 

 return;

}

 

and messuring AN1:

void MessureChargeCurrent()

{

/*- Meßvorgang -*/

ADCon0 = 01001001b; /*- Select RA1 -*/

set_bit (ADCon0,2); /*- Start AD-Conversion -*/

 

while ((ADCon0 & 4) == 4)

{

nop();

}

 

/*- Wert in einer 16Bit Variable zusammenfassen -*/

iAmess = ADResH;

iAmess <<= 8;

iAmess |= ADResL;

 

return;

}

 

Has anybody an idea?

Thanks Prefekt

Share this post


Link to post
Share on other sites

Which PIC do you use ???

 

On a 12F675, the following test :

 

while ((ADCon0 & 4) == 4)
{
nop();
}

 

should be:

while ((ADCon0 & [B]2[/B]) == [B]2[/B])
{
nop();
}

 

But i don't know if the Adcon0 register have the same shape on each model...

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...