help setting up 16F886 for ADC


Results 1 to 17 of 17

Threaded View

  1. #2


    Did you find this post helpful? Yes | No

    Default Re: help setting up 16F886 for ADC

    I think that the code "adcin3x" is for the old pic16F877, not a pic16f887. The adc in the newer chips have more registers. I have found the adcin command does not always work. So I use a manual set and read routine. Below is an example for 10bit, I think the 8bit result will be in the ADC_AN0.HIGHBYTE when the adc is set to left shift?

    Code:
    ADC_AN0 var WORD '10bit result 
    ADC_AN1 var WORD '10bit result
    
    'Read AN0
    '--------------------------------------------------------------------------
    ADCON0 = %11000011   'Set adc channel = AN0
    
    WHILE ADCON0.1 = 1  'WAIT FOR CONVERSION
    
        WEND
         ADC_AN0.HIGHBYTE = ADRESH
         ADC_AN0.LOWBYTE  = ADRESL
    
    'Read AN1
    '--------------------------------------------------------------------------
    
    ADCON0 = %11000111   'Set adc channel = AN1
    
    While ADCON0.1 = 1  'WAIT FOR CONVERSION
    
         WEND
    
    
         ADC_AN1.HIGHBYTE = ADRESH
         ADC_AN1.LOWBYTE  = ADRESL
    '---------------------------------------------------------------------------
    Last edited by mark_s; - 11th July 2016 at 23:35.

Similar Threads

  1. 16f886
    By Larry in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 4th November 2008, 16:57
  2. 16f886
    By hvacrtech in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 27th May 2008, 05:06
  3. Setting Address via ADC
    By breesy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 14th October 2007, 14:33
  4. Setting up ADC....
    By robertmark68 in forum General
    Replies: 1
    Last Post: - 11th August 2006, 18:08
  5. Setting Up Adc Ports
    By GEEZER in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 22nd August 2005, 03:04

Members who have read this thread : 1

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