i just wanna ask..by the way i'm new to this pic and programming...
if is it ok to used port A if i hv used the port A0 for temperature circuit input...i mean i have analog all port A..
ps: i hope this is not a stupid question~
inservi
Joined: 13 May 2007 Posts: 128
Posted: Sat Jun 02, 2007 1:05 pm
Hello,
you can config the ports with the constant defined in the .h file.
for example, here are the constant defined in the PIC18F252.h
Code:
// Constants used in SETUP_ADC_PORTS() are:
#define NO_ANALOGS 7 // None
#define ALL_ANALOG 0 // A0 A1 A2 A3 A5
#define AN0_AN1_AN2_AN4_VSS_VREF 1 // A0 A1 A2 A5 VRefh=A3
#define AN0_AN1_AN3 4 // A0 A1 A3
#define AN0_AN1_VSS_VREF 5 // A0 A1 VRefh=A3
#define AN0_AN1_AN4_VREF_VREF 0x08 // A0 A1 A5 VRefh=A3 VRefl=A2
#define AN0_AN1_VREF_VREF 0x0D // A0 A1 VRefh=A3 VRefl=A2
#define AN0 0x0E // A0
#define AN0_VREF_VREF 0x0F // A0 VRefh=A3 VRefl=A2
#define ANALOG_RA3_REF 0x1 //!old only provided for compatibility
#define RA0_RA1_RA3_ANALOG 0x4 //!old only provided for compatibility
#define RA0_RA1_ANALOG_RA3_REF 0x5 //!old only provided for compatibility
#define ANALOG_RA3_RA2_REF 0x8 //!old only provided for compatibility
#define RA0_RA1_ANALOG_RA3_RA2_REF 0xD //!old only provided for compatibility
#define RA0_ANALOG 0xE //!old only provided for compatibility
#define RA0_ANALOG_RA3_RA2_REF 0xF //!old only provided for compatibility
So, you can write :
Code:
setup_adc_ports(AN0);
for set only A0 as analogue port.
dro _________________ in médio virtus
dasilvarsa
Joined: 17 May 2007 Posts: 5
Posted: Tue Jun 05, 2007 6:07 am
It is possible to use PortA for Analog as well as digital inputs.
The technique is to configure the port to analog read ther ADC and the configure the port back to digital.
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