CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Adc in Pic 16F88

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
oxxyfx



Joined: 24 May 2007
Posts: 97

View user's profile Send private message

Adc in Pic 16F88
PostPosted: Wed Aug 22, 2007 4:18 pm     Reply with quote

Hello,

this may be a stupid beginner question, but I can't figure this out. The datasheet says that the above PIC has 7 x 10Bit ADC pins.

However all I am reading back from the ADC is 8 bit values. Is there a way to change this to 10 bit resolution? I could use the extra resolution in my program...

Thanks,
Ox.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Wed Aug 22, 2007 4:24 pm     Reply with quote

look to the help file for #device ADC
Quote:
Relevant Preprocessor:
#DEVICE ADC=xx Configures the read_adc return size. For example, using a PIC with a 10bit A/D you can use 8 or 10 for xx- 8 will return the most significant byte, 10 will return the full A/D reading of 10 bits

Remember to store this in a variable that can hold 10 bits,... int16 or bigger.
oxxyfx



Joined: 24 May 2007
Posts: 97

View user's profile Send private message

PostPosted: Wed Aug 22, 2007 6:21 pm     Reply with quote

Thank you, I found that as the second line in my .h file.

Now, if I change the
#Devide ADC =10

and then the original code:

Code:

int8 adc_conversion(Int8 adc_value);
int8 value;
int8 y;
...

Void main() {
...
y = adc_conversion(value);
...
}

Int8 adc_conversion(int8 adc_value) {
         value = read_adc();
         delay_us(10);
}


to 16 bit integers:

Code:

int16 adc_conversion(Int16 adc_value);
int16 value;
int16 y;
...

Void main() {
...
y = adc_conversion(value);
...
}

Int16 adc_conversion(in16 adc_value) {
         value = read_adc();
         delay_us(10);
}


Then the compiler reports back with an error:

y=adc_conversion(value) used but not defined.

The compiler version is 4.023

If I change it back to 8 bit values, it compiles without error - even if the #device adc is left on 10.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Thu Aug 23, 2007 8:15 am     Reply with quote

Did you also change the adc_conversion(); function itself?
So it returns an int16?
Go ahead and post a small complete test case showing the error.
oxxyfx



Joined: 24 May 2007
Posts: 97

View user's profile Send private message

PostPosted: Thu Aug 23, 2007 5:08 pm     Reply with quote

I did it today again just now, and it worked. Thanks for your help. Last night I might have been too tired and possibly misstyped something.

Thanks again for your help.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group