Question on debug reporting re A/D in a 18f2450

Discussion on both general simulation and Proteus VSM microcontroller simulation.
Post Reply
Tim_B
Professional User
Posts: 145
Joined: Mon 2007-01-29 15:27
Location: Usa
Contact:

Question on debug reporting re A/D in a 18f2450

Post by Tim_B »

Hi Isis team
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 
And I'm getting this debug error
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
www.triplogik.com for your mileage management needs.
Roshan
Professional User
Posts: 27
Joined: Thu 2006-03-09 15:07

Re: Question on debug reporting re A/D in a 18f2450

Post by Roshan »

set adcon1.7 before ad conversion & see result
Roshan
Tim_B
Professional User
Posts: 145
Joined: Mon 2007-01-29 15:27
Location: Usa
Contact:

Re: Question on debug reporting re A/D in a 18f2450

Post by Tim_B »

ADCON1.7 is an unimplemented bit, if you thinking about right justification its on ADCON2.7

Besides my concern is with the A/D error messages unless you turn them off the sim grinds to a halt and that it produces 0 even if you tie it to 5v
www.triplogik.com for your mileage management needs.
Ettore
Labcenter Staff
Posts: 2932
Joined: Fri 2006-03-03 11:56
Location: Milan
Contact:

Re: Question on debug reporting re A/D in a 18f2450

Post by Ettore »

I'm looking at this. I'll contact you ASAP.
Kind regards,
Ettore Arena - Labcenter Electronics.
Post Reply