|
|
View previous topic :: View next topic |
Author |
Message |
ik1wvq
Joined: 21 Feb 2004 Posts: 20
|
RA0 (as ANALOG) and RA3 (as VREF+) usage question on PIC18F |
Posted: Fri Jan 01, 2010 3:51 am |
|
|
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
|
|
Posted: Fri Jan 01, 2010 10:08 am |
|
|
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 |
|
|
|
|
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
|