![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
GEORGE Guest
|
setting port E as an analog input and other analog questions |
Posted: Sun Mar 07, 2004 1:57 am |
|
|
hello,
I am trying to use only port E as analog inputs, i put in the code like:
setup_adc_ports(xxx_ANALOG);
what do i put in for xxx I tried E0_E1_E2 and get an Undefined identifier error on compile. It works fine with say A0_A1, ??????
I looked in the 16f877.h file and it looks like i cant set just the E port to analog without setting port A. Is there a way to do this?
one other thing i wanted to ask is with regard to the reference voltage. do I connect this to the +5v supply or is this used as an output voltage reference?
thanks guys. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
Re: setting port E as an analog input and other analog quest |
Posted: Sun Mar 07, 2004 4:51 am |
|
|
GEORGE wrote: | hello,
I am trying to use only port E as analog inputs, i put in the code like:
setup_adc_ports(xxx_ANALOG);
what do i put in for xxx I tried E0_E1_E2 and get an Undefined identifier error on compile. It works fine with say A0_A1, ??????
I looked in the 16f877.h file and it looks like i cant set just the E port to analog without setting port A. Is there a way to do this?
one other thing i wanted to ask is with regard to the reference voltage. do I connect this to the +5v supply or is this used as an output voltage reference?
thanks guys. |
The answer to all such questions, is _read the chips data sheet_. If there is a feature supported by the chip, that you can't see how to implement, then start asking questions.
The chip itself does _not_ allow port E to be used as analog on it's own. Hence the compiler does not offer options to do this.
'output voltage reference'?. There is no 'output', so how can there be an 'output voltage reference'...
You can connect the Vref to what you want, with certain 'constraints'. The first thing to remember, is that the +5v supply _will_ be noisy (because of all the digital circuitry attached to it). Hence, for the best AD accuracy, you may want to supply a specially smoothed 5v rail (assuming you want to measure over the range 0-5v). It is common to use a different (lower) analog reference voltage, but the accuracy of the AD, declines once the voltage drops below about 2v. Again details of the exact voltage are in the MicroChip application notes.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
guest Guest
|
|
Posted: Mon Mar 08, 2004 6:16 pm |
|
|
ive only found that it works if you set all ports as analog |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Tue Mar 09, 2004 7:59 am |
|
|
guest wrote: | ive only found that it works if you set all ports as analog |
RTFM...
The only options that give E1 and E2 as analog are:
ALL_ANALOG
ANALOG_RA3_REF
ANALOG_RA3_RA2_REF
You can have E0 as analog without E1 and E2, with:
ANALOG_NOT_RE1_RE2
ANALOG_NOT_RE1_RE2_REF_RA3
ANALOG_NOT_RE1_RE2_REF_RA3_RA2
The possible options are listed in the data sheet, on page 112, under the reference for register 11-2.
CCS can't do anything that the chip won't do, hence allways start by reading the manual for the chip...
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|