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

setup_adc_ports with 18F452

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



Joined: 19 Nov 2003
Posts: 45
Location: Oxford

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

setup_adc_ports with 18F452
PostPosted: Mon Feb 16, 2004 8:56 am     Reply with quote

I want to use RA3 as a voltage ref and Just RA0 as a single analogue in. I am writing this code

Code:

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



and when I compile it in MPLAB i get the following statment

Undefined identifier RA0_ANALOG_RA3_REF

If i use

Code:

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


it compiles

Any ideas, answers on a postcard please

I am using a
pic18F452
MPLAB 6.3
PCH 3.180
Chas
Guest







PostPosted: Mon Feb 16, 2004 9:10 am     Reply with quote

What you are attempting is not an option. The least number of analog inputs that can be configured with RA3 as an external Vref is 2, RA0 and RA1. If you only want one analog input with an external reference, you can use both a positive and negative reference, but this still requires 3 pins, so you are no gaining anything.

Refer to the available configurations on page 182 of rev B of the 18FXX2 data sheet (DS39564B).

I just went through this on a project with the same device and ended up wasting the second analog input pin (A1).
Guest








PostPosted: Mon Feb 16, 2004 9:32 am     Reply with quote

Works thanks alot!!!
homfray



Joined: 19 Nov 2003
Posts: 45
Location: Oxford

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

PostPosted: Mon Feb 16, 2004 9:36 am     Reply with quote

If i wanted to use RA2 as a neg ref how would I do that

setup_adc_ports( RA0_RA1_ANALOG_RA2_RA3_REF );

doesn't seem to work
homfray



Joined: 19 Nov 2003
Posts: 45
Location: Oxford

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

PostPosted: Mon Feb 16, 2004 9:38 am     Reply with quote

however this does work

RA0_RA1_ANALOG_RA3_RA2_REF

For all ewbies like me is you look at the .h file for your chip it has all the commands in there i.e. 18F452.h
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