I'm trying to sim my code in a 18f2450 and starting on the A/D conversions
I'm running this code
Code: Select all
Device 18f2450
XTAL 16
Dim VAR1 As Word
ADCON0 = 0 ; AD channel 0 is used
ADCON1 = %00001110 ; Only Channel 0 is used and VRef- = VSS Vref+ = VDD
ADCON2 = %10000011 ; FOSC/2, 6 TAD, Right justified
ADCON0.0 = 1 ; Turn on the AD unit
While 1 = 1
ADCON0.1 = 1 ; Start the conversion
While ADCON0.1 = 1:Wend ; Wait until its stopped
VAR1.BYTE0 = ADRESL ; Read the data
VAR1.BYTE1 = ADRESH
DelayMS 200
Wend
Voltage references for ADC conversion yeald a 0V range (V+ = 0, V- = 0)
Does this mean that you have not implemented the A/D converter in this model or are you trying to say the config bits are set wrong? I have treble checked the Mchip data sheet and I'm sure its right.
BTW it's not returning the right result
Thanks
Tim