A/D conversion with PIC18F67J50


Results 1 to 10 of 10

Threaded View

  1. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    You conversion clock seems a bit high @48MHz operation, and your first example in C used ANCON0, not yours.... yet...

    While it's not a problem for now, one day you may need to disable some analog feature on this PIC... however, seems ANCON0 and ANCON1 are not included in PBP 2.50c, so I guess the following would be handy one day or another.
    Code:
            '
            '       Configure ADC
            '       =============
            ANCON0  VAR BYTE EXT    ' not included in PBP2.50c
            ANCON1  VAR BYTE EXT    ' not included in PBP2.50c
            
            ANCON0 = %10011110
                   '  -xx------ Not Implemented
                   '  1--1111-- AN7, & AN<4:1> = Digital
                   '  -------0- AN0 = Analog
                   
            ANCON1 = %11111111
                   '  11111111- AN<15:10> = Digital
                                         
            ADCON0 = %00000001
                   '  0-------- VCFG1, Vref- 0 = AVss (1=AN2)
                   '  -0------- VCFG2, Vref+ 0 = AVdd (1=AN3) 
                   '  --0000--- CHS<3:0>, Channel select -- 0
                   '  ------0-- Go/Done, don't care for now
                   '  -------1- ADON, Enable ADC
                      
            ADCON1 = %10000111
                   '  1-------- ADFM, Right justified result
                   '  -0------- ADCAL, Normal A/D converter operation
                   '  --000---- ACQT<2:0>, A/D Aquisition time = 0 Tad
                   '  -----111- ADCS<2:0>, A/D conversion clock = FRC
                    
            '
            '       Hardware Aliases
            '       ================
            GoDone      var ADCON0.1 ' StartConversion = 1, Conversion done = 0
            
            '
            '       Software Variables
            '       ==================
    @ADVal = ADRESL
            ADVal       VAR WORD EXT
            
    Start:
            pauseus 10  ' Acquisition time        
            GoDone = 1
            While GoDone : Wend
            LCDOUT $FE, 1, "Value: ", DEC ADVal
            PAUSE 250
            GOTO START
    EDIT: for some odd reason, ANCON0 & ANCON1 are commented in PIC18EXT.BAS, i'd sent an e-mail to Melabs, obviously they must have a reason for that.
    Last edited by mister_e; - 6th May 2009 at 23:04.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Fast / low resolution A/D conversion
    By AndrewC in forum General
    Replies: 7
    Last Post: - 7th April 2009, 13:18
  2. A/D conversion problem in 18F2520, 2523, 2550 etc.
    By selimkara in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 10th March 2008, 17:26
  3. A/D conversion problem on 18F4431
    By ttease in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 11th April 2007, 00:03
  4. A/D converter fails?
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 14
    Last Post: - 13th February 2006, 19:57
  5. Strange A/D conversion...
    By Christos_K in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th June 2005, 02:35

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts