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 support@ccsinfo.com

Analog to digital conversion

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








Analog to digital conversion
PostPosted: Tue Jan 16, 2007 8:05 am     Reply with quote

I am trying to read the analog voltage on pin A1. Using the development board, I modified example 7 from the book

setup_adc_ports( RA0_ANALOG );
setup_adc( ADC_CLOCK_INTERNAL );
set_adc_channel( 0 );

to use ( RA1_ANALOG ) instead, but the compiler gave me the error "Undefined identifier RA1_ANALOG". What am I doing wrong?
Ttelmah
Guest







PostPosted: Tue Jan 16, 2007 8:14 am     Reply with quote

First, what chip?.
Now look at the data sheet for the chip. What 'patterns' of analog inputs a supported?. Gnerally, on most chips, you cannot have RA1, as analog on it's own. The patterns normally run something like:
AN0
AN0+AN1+AN3
etc.

Hence there is no 'RA1_ANALOG' definition, since the chip does not support just having this pin as an analog input....

Best Wishes
Guest








PostPosted: Tue Jan 16, 2007 8:25 am     Reply with quote

Thanks for the quick reply!

Its the PIC18F452. I've got the data sheet pdf in front of me, looking at section 17 (A-D Conversion) I haven't found what combinations are allowed yet, but the one you suggested seems to work OK. Thanks :-)
jfk1965



Joined: 21 Oct 2003
Posts: 58

View user's profile Send private message

PostPosted: Tue Jan 16, 2007 8:40 am     Reply with quote

Look in the PICC/ devices folder and find the 18F452.h file and scroll down to the A/D section you will see all the valid options for that chip.

JFK
Guest








PostPosted: Tue Jan 16, 2007 8:46 am     Reply with quote

Ah yes, there they all are - loads of options.

Thanks!
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