View previous topic :: View next topic |
Author |
Message |
homfray
Joined: 19 Nov 2003 Posts: 45 Location: Oxford
|
setup_adc_ports with 18F452 |
Posted: Mon Feb 16, 2004 8:56 am |
|
|
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
|
|
Posted: Mon Feb 16, 2004 9:10 am |
|
|
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
|
|
Posted: Mon Feb 16, 2004 9:32 am |
|
|
Works thanks alot!!! |
|
|
homfray
Joined: 19 Nov 2003 Posts: 45 Location: Oxford
|
|
Posted: Mon Feb 16, 2004 9:36 am |
|
|
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
|
|
Posted: Mon Feb 16, 2004 9:38 am |
|
|
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 |
|
|
|