16F876 ADCON,CMcon,Tris settings


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1

    Default 16F876 ADCON,CMcon,Tris settings

    Hi

    This is the first time I will use a 16F876 asfar as i can read in the forum, some confusion on the port configuration:

    I need to have:
    RA0-RA3,RA5(AN4) analog in (10bit ADC), RA4 digital out,
    RB0-RB3 + RB6,7 digital out,RB4,5 digital input,
    RC0-RC5 digital out,RC6+7 TX+RXD usart

    I think i have to set:

    ADCON1= %00000010 ' sets RA4 to digital,RA0-3,RA5 analog in, (Bit 7 ? Left or right justified ?)
    Trisa %00101111
    Trisb %00110000
    Trisc %10000000

    ADCON0= ?
    CMCON= ?
    how do I set 10bit ADC ?

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Looks good. Write ADCON1= %10000010 for 10-bit.

    Note: The 16F876 does not have comparators. The A version does.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Thanks Bruce

    What if I use the 16F876a version ?

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    The A version has comparators so then you would use CMCON = 7. Even though it defaults to this value at POR, it's good to include this so you remember. Some PIC types with comparators don't default to disabled.

    A/D looks pretty much the same.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    As well as implicitly disabling the COMPARATORS, I also disable the VOLTAGE REFERENCE MODULE on the 16F877A...

    CMCON=7
    CVRCON=0

    Those two lines are the ONLY differences between the 'A' and the non-A I've ever included.

    You can then progress up to the 18F242/252 (with minor ADC software changes), but there's a HARDWARE difference with the ADC's once you go up to the 18F2420/18F2520 series (eg ADCON1 ADC Configuration %xxxx0100 from the 16F876 can't be pin configured on the 18F2420's).
    Last edited by Melanie; - 10th March 2010 at 18:59.

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Good catch Melanie.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. Config settings
    By Adrian in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th December 2007, 18:24
  2. 16F876 Usart Receive
    By syscoder in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 21st March 2007, 15:43
  3. Changing Settings ???
    By tico in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 28th December 2006, 03:10
  4. 16F876 : settings for 40Mhz
    By mischl in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 11th April 2005, 16:36
  5. Need help with migration 16F876 -> 18F252
    By NavMicroSystems in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 24th February 2004, 16:22

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