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

RA0 (as ANALOG) and RA3 (as VREF+) usage question on PIC18F

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



Joined: 21 Feb 2004
Posts: 20

View user's profile Send private message

RA0 (as ANALOG) and RA3 (as VREF+) usage question on PIC18F
PostPosted: Fri Jan 01, 2010 3:51 am     Reply with quote

Hi,

I need to use RA0 as analog input, and RA3 as VREF+, with RA1 and RA2 as normal DIGITAL inputs/outputs. (on PIC18F2620)

It is possible to make this?

I ask this because I suppose what RA3 must be defined as ANALOG for
using as VREF, and then RA1 and RA2 also bacame defined as analog ...
(AN0_TO_AN3_ANALOG)

It is correct???

Thanks in advance.

regards

Mauro
Ttelmah
Guest







PostPosted: Fri Jan 01, 2010 10:08 am     Reply with quote

RA3, has to be defined as Vref, not as an analog input.

What you need, is:

setup_adc_ports(AN0 | VSS_VREF);

This says "set AN0 as an analog input" (first part of what you want), and then says "set the voltage reference 'low', to use Vss, and the voltage reference 'high' to use it's Vref input (second part...)".

The Vref settings are separate from the analog input selection.

Look at the section in the processor include file, for "Constants used in setup_adc_ports", and read the comments on the lines, and partiularly the second block of stuff headed "The following may be OR'ed in with the above using |".

Best Wishes
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