-
18f452 ADC config
Hi to all,
I am going to set up the PIC18F452 having a clock speed of 40 Mhz in order to read the follwing analog inputs:
> analog input connected to AN0 pin_2
> Vref+ connected to AN3 pin_5
> Vref - connected to AN2 pin_4
Question_1:
How do I have to set ADCON0 register and ADCON1 register to achieve this set up ?
Question_2:
Do I have to read ADRESL and ADRESH relevant to AN0 ? or I do have to read AN2 and AN3 register in addition to AN0?
Thanks a lot for any help
Regards,
Ambrogio
-
18f452 adc
you dont need to set adcon0 register if you are using picbasic.
Use Adc defines ;
Code:
DEFINE ADC_BITS 10 ' ADCIN resolution (Bits)
DEFINE ADC_CLOCK 3 ' ADC clock source (Fosc/8)
DEFINE ADC_SAMPLEUS 50 ' ADC sampling time (uSec)
YOU HAVE TO SET ADCON1 REGISTER TO CHOICE WITCH PORT ANOLOG OR DIGITAL.
Code:
ADCON1.7 = 1 ; Right justified.
ADCON1.3 = 1 ; PORTA.0 - ANALOG , AN2 - VREF(-) , AN3 - VREF(+)
ADCON1.2 = 1
ADCON1.1 = 1
ADCON1.0 = 1
MAIN :
ADCIN 0 , ADVAL
PAUSE 10
GOTO MAIN
-
Hi ,
Thanks very much for adc setting help.
Now it is working well.
Could you please spend few words for me about the following :
DEFINE ADC_CLOCK 3 ' ADC clock source (Fosc/8)
DEFINE ADC_SAMPLEUS 50 ' ADC sampling time (uSec)
I am working with a 40 Mhz clock speed: does those defines affect the accuracy of the measure ( in some way ? Fosc/2 or fosc/32 ... sampleus=150 ... ).
Thanks again
regards,
Ambrogio
-
pic multi-calc
i think mister-e's great program will help you.
program cointains a adc-calc.
http://www.picbasic.co.uk/forum/show...light=mister-e